[Closed] Lists posts by language

Home Support English Support [Closed] Lists posts by language

This topic contains 1 reply, has 2 voices, and was last updated by  Mihai 4 years, 10 months ago.

Author Posts
Author Posts
October 30, 2009 at 11:02 am #13366

garrido

Hi there,
I am setting up my first bi-lingual blog with WPML, and as I'm not a PHP programmer, I'm having problems with what must be a simple issue. My sidebar lists recent posts. However, it is listing recent posts in all languages. I would like the sidebar to list the recent posts in whatever language the blog is being displayed in. The code in use currently is this:
<pre>

<?php $posts = get_posts("numberposts=10&orderby=post_date&order=DESC"); foreach($posts as $post) : ?>

<li><a>"><?php the_title(); ?></a> - <?php the_ID(); ?></li>
 <?php endforeach; ?>

</pre>
I will have the same issue with tags and comments.
I know I can use ICL_LANGUAGE_CODE to find the language the page is being displayted in, but how do I get a post's language code? Sorry if this is too basic, but I'm not a programmer and this looks like something so simple…

November 2, 2009 at 8:32 pm #13368

Mihai
Forum moderator

The function get_posts() is sendinfg suppress_filters=1 by default to thw WP query that's being generated.
What you can do is add suppress_filters=0 as an argument:
<pre>

<?php $posts = get_posts("numberposts=10&orderby=post_date&order=DES&suppress_filters=0"); foreach($posts as $post) : ?>

</pre>
This will ensure that the WPML filters will be used so you should see the posts in the correct language.

The topic ‘[Closed] Lists posts by language’ is closed to new replies.