Open
Overview of the issue
The native WordPress function has_category does not work for translated posts.
An example of this is as follows:
- We have a category with the English slug “test” and its French translation “test-fr”.
- This category is assigned to posts.
- When you invoke the has_category(“test”) inside a loop in your theme’s single.php file, it returns true for the default language but false for the translation.
Workaround
Define a new filter in your theme’s functions.php file:
function wp_has_category ($category) { $category = get_term_by('name', $category, 'category'); return has_category($category); } add_filter('wp_has_category', 'wp_has_category', 10, 1);
Replace the has_category function with this new filter:
apply_filters( 'wp_has_category', 'test' )
This filter takes the translated category based on the name of original one and checks if the translated category is assigned to a post.
Hi folks,
i would like to know: how can i create a new topic theme on your support site?
Did’t find the possibility…?? Thanks a lot for a short hint….mailto: info@arnholdsart.com
Hi,
please scroll down the page and locate the “Create New Topic in “English Support”” section.
The WPML plugin is duplicating my website title on Search Engines…
This is really bad for SEO, can someone help me, please?????
Please register a ticket in our support forum.