Skip to content Skip to sidebar

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.

Tagged: 

This topic contains 1 replies, has 2 voices.

Last updated by Andreas 2 years, 12 months ago.

Assisted by: Andreas.

Author Posts
January 27, 2023 at 11:43 am #12903651

sigbjornV-3

Hi! Is it possible in a WP_Query to show posts from both default language + translated language?

Example: I have 100 posts in Norwegian assigned to different categories, but only 20 of them is translated to english. When the visitor is english, I want to show all 100 posts even though they are not translated to english.

I have set "use translation if available or fallback to default language" as a option for my post type, but using a WP_Query only the translated posts to english show up

January 27, 2023 at 1:03 pm #12904037

Andreas

Hello there

Thank you for contacting us. I am happy to help you.

WP_Query is not enough to query translations, you need to use our hooks also in order to make it possible.

You can read all hooks here:
you.https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

I guess you need to look at this section :
https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/#retrieving-localized-content

Last but not least, I would like to inform you, that supporting custom code is out of the scope of this support but giving you some hints is always welcome! 🙂

I hope this helps. Please let us know how it goes or if you need any further assistance. I'll gladly help you. 🙂

Regards,
Andreas