Resolved
Overview of the issue
Since the WordPress 4.8 release, the tax_query query and get_term_by() functions are returning null in secondary languages when you pass the slug or name parameters.
Workaround
As a workaround for this issue pass the ID parameter instead for tax_query query and get_term_by() function. Additionally, you can use our the wpml_object_id function to recover your term translations:

1 2 3 4 5 | $postid = get_the_ID(); //get current post $termid = wp_get_object_terms( $postid , 'category' ); //get terms assigned to post $termobj = $termid [0]; //use only first term value (can be adjusted) $term = apply_filters( 'wpml_object_id' , $termobj ->term_id, 'category' ); //Translate the term ID $term2 = get_term_by( 'id' , $term , 'category' ); //Get the translated term object |
How can you get the term ID if get_term_by() is returning null ?!
Please do not advise updating when bugs like these are still live, things do break..
It could be caused by trying to get a term that is in a language different from the current language.
In any case, you should open a new topic in our support forum and we will resolve any issues you have:
https://wpml.org/forums/forum/english-support/