Skip Navigation

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.

This topic contains 2 replies, has 2 voices.

Last updated by anthonyL-2 5 years, 6 months ago.

Assigned support staff: Beda.

Author Posts
March 16, 2015 at 6:44 pm #579507

anthonyL-2

Hi, we are using the WPML -> "Languages" - Blog posts to Display: All posts (display translation if it exists or posts in default language otherwise).

This works great for us to allow us to find all posts from a custom post type irrelevant if there is a translation.

However, we would like to not use this setting elsewhere i.e. Only display specific language posts. Is there a way we can do this before the get_posts or query_posts query?

Alternatively:
How can we specify a specific language when querying posts irrelevant of what language the user is currently viewing.

March 17, 2015 at 3:15 pm #580315

Beda

Hello Anthony

Thank you for the Debug infos

I see you would need some Post Types to display Translation OR Original in ANY case, and other Post Types you would like to display ONLY the language you choose.

This is, with the current WPML Options and Settings, not possible.

That Screen (as in your screenshot) will affect all post types in your WP Website.

The Goal you try to achieve would need some custom programming work which is beyond the scope of our support.

At this point I would suggest you consider contacting one of our certified partners from this link:
http://wpml.org/documentation/support/wpml-contractors/
You will get the custom assistance you need to get on with your project.

Before doing so please have a look also here:
http://wpml.org/documentation/support/wpml-contractors/guidelines-for-people-looking-for-consulting-help/

Please apologize that I can't be of better help here in this case.

Thank you for your understanding.

March 17, 2015 at 4:24 pm #580410

anthonyL-2

Thanks Beda,

I did guess as much and after a bit of Googling achieved what we were looking for by switching the language before running the query:

			
global $sitepress;
$current_lang = $sitepress->get_current_language(); //save current language
$sitepress->switch_lang("en");

if ($posts = query_posts($args)) {
			
 //Switch back to original language
 $sitepress->switch_lang($current_lang);

Hopefully this might help someone else in the future.

Cheers
Anthony