Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

Chouby on "[Plugin: Polylang] Add a taxonomy automatically based on language?"

$
0
0

As stated above, you should use 'pll_save_post' hook instead of 'save_post', it will avoid you setting the default language as it is already done. You should also use $polylang->model->get_post_language() and $polylang->model->set_post_language() rather than $polylang->get_post_language() and $polylang->set_post_language() (if you set WP_DEBUG to true, Polylang will issue warnings).

Then to solve your issue, you could try using this (although not tested, I guess you will catch the idea):

$languages = $polylang->get_model->get_languages_list(array('fields' => 'slug'));
$post_tags = get_the_tags($post_id);
$post_tags = wp_list_pluck($post_tags, 'slug');
$post_tags = array_diff($post_tags, $languages);
wp_set_post_tags($post_id, $post_tags);

Viewing all articles
Browse latest Browse all 11471

Trending Articles