Due to the large volume of support requests, at the moment there is a waiting time of more than 24 hours. 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 errata 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 topic contains 9 replies, has 2 voices, and was last updated by  Daniel Dvorkin 6 years, 3 months ago.

Author Posts
Author Posts
October 10, 2011 at 6:47 pm #37768


I'm using the function get_posts(); to show my custom type posts.
get_pages() doesn't seem to work with post types anymore.
Here's my code:

$mypages = get_posts( 'post_type=intro');
foreach( $mypages as $page ) {
        echo $page->post_title;

This brings me the titles from all languages.

October 10, 2011 at 6:57 pm #37770


After looking around here I fixed this problem by adding

'suppress_filters' => 0

Now my problem is the custom meta which won't show up in my secondary language.
Here's my code:

echo get_post_meta(icl_object_id($page->ID, 'post', true, 'en'), "the_name", true);
October 10, 2011 at 9:36 pm #37771

Daniel Dvorkin

You can configure WPML to automatically copy that meta to the translated post (in WPML->Translation Management->Multilingual content setup)

October 10, 2011 at 9:50 pm #37772


That would be an option but I don't want to have duplicated meta.
This used to work well with the previous versions. When I try do the same with


it works, but not with the meta.

October 10, 2011 at 9:50 pm #37773

Daniel Dvorkin

icl_object_id($page->ID, 'post', true, 'en') is returning the correct id?

October 10, 2011 at 10:15 pm #37774


Yes, but on false it doesn't return anything.
My languages are 'en' & 'zh-hans'

icl_object_id($page->ID, 'post', false, 'en')

returns nothing on both languages.
While this

icl_object_id($page->ID, 'post', true, 'en')

returns the IDs of each languages.

October 10, 2011 at 10:16 pm #37775

Daniel Dvorkin

oh, sorry, i missed it! you are quering for "post" and I see your type is "intro". Replace it in the second parameter.

October 10, 2011 at 10:20 pm #37776


Like this?

$o_ID = icl_object_id($page->ID, 'intro', false, 'en');

This returns nothing. I don't know what has changed or what I'm doing wrong because this used to work.

October 11, 2011 at 9:08 am #37777


Tested on a new install, I think the problem comes from Yoast SEO Plugin.
Without it, I'm able to use get_pages() for custom type posts and the meta show up correct.

October 11, 2011 at 11:46 am #37778

Daniel Dvorkin

uhm. Weird. Are you using the last version of Yoast SEO?

The topic ‘[Closed] get_posts() shows all languages’ is closed to new replies.