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

Chouby on "Multilanguage site and Postie"

$
0
0

Before looking at your code, I would have said no.

But looking at the function 'lookup_category', I observed that you are looking for a term_id without specifying the taxonomy (unlike native functions of WordPress). So if I well understand the code, every valid term in a taxonomy will be accepted. Am I right?

Since for Polylang, each language is a term in the taxonomy 'language', if I specify for example "English", then it should be accepted.

Then I propose the following filter (I did not test it):

add_filter('postie_post', 'add_language');

function add_language($post) {
	foreach ($post['post_category'] as $key=>$cat) {
		if ($term = term_exists($cat, 'language') {
			global $polylang;
			$polylang->set_post_language($post['ID'], $term['term_id']);
			unset($post['post_category'][$key]); // otherwise I believe that we will create a new category
		}
	}
	return $post;
}

What do you think of this?


Viewing all articles
Browse latest Browse all 11471

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>