My client uses WPML to translate their content posts. I am finalizing the adaptation of their WordPress project, and I am faced with an issue where I can only retrieve posts in the base language, namely English. Below is my code:
<!-- loop through posts start -->
<?php
$max_posts = 5;
$i = 0;
// do not use query_posts
// see http://wordpress.stackexchange.com/questions/69609/why-is-custom-template-not-seen-as-page-with-is-page/69618
// see http://codex.wordpress.org/Class_Reference/WP_Query
// query according to language
$query;
if($language == FR)
{
$query = new WP_Query('category_name=nouvelles,portfolio-fr');
}
else
{
$query = new WP_Query('category_name=news,portfolio');
}
while($i < $max_posts):
$query->next_post();
$id = $query->post->ID;
$title = get_the_title($id);
$date = get_the_date();
$permalink = $query->post->guid;
$i++;
if($id):
?>
<a
href="<?php echo $permalink; ?>"
class="news-link"
>
<span class="title"><?php echo $title; ?></span>
<span class="date"><?php echo $date; ?></span>
</a>
<?php
endif;
endwhile;
?>
<!-- loop through posts end -->
Basically, this works fine in English, but on the French side, even though the categories are right, and the post is in the proper category, there is no content.
Below is a comparison between the English posts list (left), and the French posts list. WPML somehow links the two together.
Link to image: http://i.stack.imgur.com/bGefM.png (site prevents me from posting an image...)
I would like to know what to do to get the content? Thanks.