Hellp !
I'm working on a bilingual (chinese & french) language learning platform.
I have posts that actually need to be displayed on the same page. The post in french is a list of words, that are translated in chinese using the WPML ui.
For example I have a post about the notion of birth that is tagged in my taxonomy as the term "life". BTW I have others posts tagged in other terms such as "eat".
For the summary, I need to display all the posts, sorted by my taxonomy's terms.
So you have :
Life - birth - death - youth - ..
Eat - meat - vegetables - Flour - ...
To do so, I have use this simple query : (taxonomy25366 is the taxonomy for the large themes such as "life" and "eat")
$terms = get_terms('taxonomy25366','parent=0');
foreach ($terms as $term) {
$wpq = array('taxonomy'=>'taxonomy25366','term'=>$term->slug,'posts_per_page' => -1);
$myquery = new WP_Query ($wpq);
$article_count = $myquery->post_count;
if ($article_count){
echo "<h3 class=\"term-heading\" id=\"".$term->slug."\">";
echo $term->name;
echo "</h3>";
echo "<ul>";
while ($myquery->have_posts()) : $myquery->the_post();
echo "<li><a href=\"".get_permalink()."\">".$post->post_title."</a></li>";
endwhile;
echo "</ul>";
}
}
In french it works perfectly, but once I toggle to chinese here is a sample of what appears :
Life - birth - death - youth - meat - vegetables - flour
Eat - birth - death - youth - meat - vegetables - flour
So all the posts are displayed in each category regardless of my taxonomy... I wondered if the custom taxonomies work for all the languages.
I found out that my chineses posts are perfectly tagged in the taxonomy. I put that line at the beginning of my single.php to check it (when heading to the chinese permalink of the post), and it is...
$theme25366 = strip_tags(get_the_term_list( $post->ID, 'taxonomy25366', '', ', ', '' ));
it returns the right term...
I eventually found a solution, but it causes a function that takes a lot of time for the server to execute. It just checks if the post that is going to be displayed is actually in the right term.
if(($term->name)==$theme25366){
echo "<li><a href=\"".get_permalink()."\">".$post->post_title." ".$thumb_target_title."</a></li>";
}
I wonder if you could help me modify that line to make this simplier, so it works in both french and chinese the same way.
$wpq = array('taxonomy'=>'taxonomy25366','term'=>$term->slug,'posts_per_page' => -1);
Super thanks! Yves