This thread is resolved. Here is a description of the problem and solution.

Problem: Custom template for custom post type does not load posts using get_term() function.

Solution: The problem was that while the taxonomies had been translated, the posts for the custom post type had not translated. If you don't want to translate the posts, set them as "Translatable - use translation if available or fallback to default language" in WPML -> Settings -> Post Type Translations.

Relevant Documentation:

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 5 replies, has 2 voices.

Last updated by jiriS-2 1 year, 7 months ago.

Assigned support staff: Ricardo Alday.

Author Posts
October 16, 2018 at 7:12 am


I am trying to:
In my template file: check if certain post has term. If so, show the post. Here is the code:

while( $vyplne->have_posts() ) {
															//$output.= 'currlangID: '.$subcategory->term_id.'<br>';
															$CScategoryid = apply_filters( 'wpml_object_id', $subcategory->term_id, 'kategorie_vyplni', FALSE );
															$currentterms = wp_get_object_terms( $post->ID, 'kategorie_vyplni');
															  $output.= '<p>';
															  $output.= 'subcategoryID: '.$CScategoryid.'<br>';
															  $output.= 'associated categories:<br>';
															  foreach($currentterms as $term){
																$output.= $term->term_id .'<br>';
															  $output.= '</p>';
															if ( has_term( $CScategoryid, 'kategorie_vyplni', $post->ID ) ) {
																$output.= '<a href="'. get_the_permalink() .'" class="d-flex flex-column px-1" data-toggle="sideModal" data-target="#sideModal" title="'. get_the_title() .'">';
																$output.= get_the_post_thumbnail();
																$output.= '<small>'. get_the_title() .'</small>';
																$output.= '</a>';

full path for used template file is: wp-content/themes/vptrend/page-templates/vyrobky.php

Link to a page where the issue can be seen:
hidden link

I expected to see:
images of doors and their names - it works in czech (primary) language: hidden link

Instead, I got:
no images and names

(hidden link is already test site - you can change what ever you want - i have backup)

October 17, 2018 at 4:42 pm #2825382

Ricardo Alday

Thank you for contacting WPML support.
I checked your site and the template. The problem is that while the taxonomies have been translated, the posts for the post type "vyplne" are not translated. I translated one of the posts and now it shows on the English page: hidden link

Just translate the rest.

Hope that helps,

October 19, 2018 at 8:51 am #2831181


Hi Ricardo,

Thank you for your responce. I does solve the problem.

Is there a way how to do it witout translating that post type? I am concern about WP performance. We have old web with around 20 000 databse entries for pages and 60 000+ entries in wp_post_meta. It slows down whole site even with caching plugin.

I do not need translating that post type. Name do not translate and there will be only links to another images

October 19, 2018 at 6:57 pm #2832862

Ricardo Alday

Try setting the post type as "Translatable - use translation if available or fallback to default language" in WPML -> Settings -> Post Type Translations but I'm not sure if that will work.

October 20, 2018 at 6:28 am #2833861


It works! Thank you!

October 20, 2018 at 6:28 am #2833862