Due to the large volume of support requests, you may experience longer wait until a supporter handles your request. We apologize for the inconvenience this causes. We do not have any recurring unknown issues so we encourage you to please search the forum for other support topics that might be helpful and to review our documentation and look at our erratas page for known issues. A supporter will respond to you as soon as possible.

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.

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

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

When creating and editing your theme’s PHP templates, you can list posts by using the get_posts function. By default, this function will return all posts for every language. To return only posts for the current language, you have two options. First is to set the 'suppress_filters' of the get_posts function to false. The second, preferred option is to return posts using the query_posts function instead.

If you choose to use the get_posts function, consider the following code snippet as an example:
$args = array(
// all your other arguments here
'suppress_filters' => false
);
$posts_array = get_posts( $args );

Tagged: 

This topic contains 7 replies, has 5 voices, and was last updated by  Craig 3 years, 8 months ago. The support staff assigned to this topic is Harshad.

Author Posts
Author Posts
May 1, 2012 at 4:50 pm #57511

Teng Shui

Hi, in my custom development work to my theme, I am using get_posts api. My problem here is it return all the posts for every language. I want it return only the posts of current view language, what should I modify for it to work? Thanks.

May 1, 2012 at 5:11 pm #57513

Harshad

Add suppress_filters=0 as an argument to your get_posts() query

May 3, 2012 at 2:02 am #57685

Teng Shui

Thanks. It's works.

June 12, 2012 at 8:04 pm #62865

Jesh

What if I have to access a single post using get_post( $post_id, $output );
Thanks in advance. 🙂

June 14, 2012 at 9:39 am #63117

Jean Paul

can you show an exemple with get_post and suppress_filters?
is it get_post( $post_id, suppress_filters = 0) ?

June 14, 2012 at 9:56 am #63119

Jesh

I have already got solution for this. Since this topic was "Resolved" I thought its better to put it as a new one.
http://wpml.org/forums/topic/get_post-by-language-instead-of-get_posts/#post-62874

get_post(icl_object_id($element_id, 'post_type', false));
get_post_meta(icl_object_id($element_id,'post_type',false,ICL_LANGUAGE_CODE), '_sample_key', true);

More related info here.
http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/

Initially, the documentation is difficult to read but once you get gist of it along with this topics on this forum, it's really helpful.

June 14, 2012 at 9:59 am #63120

Jean Paul

Thanks a lot, it's more clearer 🙂

January 31, 2014 at 8:43 am #330957

Craig

Hi Jesh,

I do not understand where you apply get_post(icl_object_id($element_id, 'post_type', false));.

I am using at the moment... $myposts = get_posts( $args );

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.