1

I have created a plug-in which permits to create a category with slugs.

There is the code :

wp_insert_term(
    'Cat1',
    'category',
    array(
    'slug' => 'slug-cat1',
));

wp_insert_term(
'Agenda',
'category',
array(
'slug' => 'slug-agenda',
'parent'=> term_exists( 'Cat1', 'category' )['term_id']

));

It permits to create my category in the default language of the website. So my question is, do you know how can i create a category as before, but i want to create it in another language than the default. I'm using Polylang to translate my website.

Have a good day.

2 Answers 2

1

You can actually make it this way:

$cat1 = wp_insert_term(
  'Cat1',
  'category',
  ['slug' => 'slug-cat1'],
);

$agenda = wp_insert_term(
  'Agenda',
  'category',
  [
    'slug' => 'slug-agenda',
    'parent'=> term_exists( 'Cat1', 'category' )['term_id'],
  ],
);

pll_set_term_language($cat1['term_id'], 'fr');
pll_set_term_language($agenda['term_id'], 'de');

Here is link to Polylang Function reference: https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/

0

Unfortunately, you need to buy the pro-version of Polylang. This is a feature, which the pro-version of the plugin provides for custom post types.

That is one of the tricks, which make people buy the pro-version.

I think Polylang pro-version starts at 99,- € (depending on your needs).

In comparison: WPML has the same features (and more) with only 79,- € I think. I have recently encountered the same problem and the cheapeast solution, was to buy the pro of WPML.

I know the answer might be not satisfying, but that's how it currently is.

6
  • Thanks for your answer then, i understand now why people are buying pro-version. Have a nice day
    – Tweak
    May 9, 2019 at 14:06
  • I will buy it. Do you know what i have to do then for my request ?
    – Tweak
    May 9, 2019 at 14:32
  • I can only tell about WPML, that is the solution that I've purchased. There should be options in the plugin which will let you do that: Special hint: browse the documentation of Polylang ;-) May 9, 2019 at 14:33
  • Hi @user3135691 , i found that Polylang can use the WPML API. Maybe i can use your solution ?
    – Tweak
    May 10, 2019 at 8:47
  • @Tweak, that doesn't make very much sense from my perspective. You don't buy the pro version of WPML just to fiddle some Polylang solution to it. Doh! Stick to one side - like the a Jedi. Either the dark side or not.. Polylang or WPML. May 10, 2019 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.