Plugin Author
Chouby
(@chouby)
disable filtering by language for these tow custom post types
That’s the easiest. You just have to deactivate the language and translation management for these custom post types in Polylang settings. Depending on the way you wrote your pll_get_post_types filter, your post types may not appear, so if they don’t try removing your filter.
Hi Chouby,
Thanks for your response.
The problem was not introduced by the pll_get_post_types. I just added this filter to try change the language of a cpt from the admin screen to see if that solves the problem, and it does.
The problem is always there whether the filter exists or not (unless if I manually change the language from the admin screen as I said) because Polylang always adds this little condition to the query :
pll_tr.term_taxonomy_id = 4
where 4 is the id of the term with value of “ar”.
I hope I explained the issue well.
Thanks again, waiting for your response 🙂
Plugin Author
Chouby
(@chouby)
If you don’t use the filter and you de-activate the language and translation management for your custom post type in Polylang settings then the Polylang shoud not filter your custom post type (and so not add this pll_tr.term_taxonomy_id = 4 in query)
I removed the filter and de-activated the language and translation management for my custom post types in Polylang settings (all check boxes for cpt’s are unchecked) and still Polylang filters the posts.
Is there any other reason why this is happening, maybe some settings I must check?
I am really sorry if I’m wasting your time, but i tried for too long to solve this on my own and I just couldn’t.
I just added the following action to functions.php, and Problem Solved:
function update_post_language( $post_id ) {
$post_type = get_post_type($post_id);
if ($post_type == 'dwqa-question' || $post_type == 'dwqa-answer') {
$term = term_exists('ar', 'language');
if ($term !== 0 && $term !== null) {
wp_set_post_terms( $post_id, array ('ar'), 'language', true );
}
}
}
add_action( 'save_post', 'update_post_language' );
Thanks again 🙂