Please make sure to update to WPML 4.3.4 before reporting any issue

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

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 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 topic contains 5 replies, has 2 voices.

Last updated by jiriS-2 1 year, 1 month ago.

Assigned support staff: Ricardo Alday.

Author Posts
October 16, 2018 at 7:12 am

jiriS-2

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() ) {
															$vyplne->the_post();
															//$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');
															if(!empty($currentterms)){
															  $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

Hi,
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,
Ricardo

October 19, 2018 at 8:51 am #2831181

jiriS-2

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

jiriS-2

It works! Thank you!

October 20, 2018 at 6:28 am #2833862

jiriS-2