admin管理员组

文章数量:1317915

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 1 year ago.

Improve this question

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.

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 1 year ago.

Improve this question

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.

Share Improve this question asked May 9, 2019 at 13:57 TweakTweak 311 silver badge8 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2

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/documentation/documentation-for-developers/functions-reference/

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.

本文标签: categoriesHow can i insert term in a specific language of Polylang