Skip to content Skip to sidebar

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

Problem:
You have a custom plugin with a custom post type. When the site's current language is set to a non-default language, such as Dutch, and you create a custom post type, it is only associated with the current language. You tried using

'lang' => 'all'

in WP_Query parameters without success. The issue is that when performing a WP_Query for the custom post type, only records in the default language are shown, filtering out records in other languages.
Solution:
To include custom post types in all languages in your WP_Query, you need to use the

suppress_filters

argument in your query. Here's how you can modify your WP_Query:
1. Set

suppress_filters = true

to fetch posts from all languages.
2. Set

suppress_filters = false

to get posts only in the currently viewed language.
For more detailed information, you can visit the WPML documentation on achieving compatibility for themes and plugins at https://wpml.org/documentation/support/achieving-wpml-compatibility-for-your-themes-and-plugins/#filter-correct-ids.

Please note that this solution might be outdated or not applicable to your specific case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket at our support forum.

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 reply, has 0 voices.

Last updated by Andrey 10 months ago.

Assisted by: Andrey.

Author Posts
July 16, 2025 at 3:12 pm #17242853

nielsS-9

Background of the issue:
I have my own custom plugin which has implemented a custom post type. If a user has their current language set to a non-default language, such as Dutch, and they create the custom post type, it is associated with the current language by WPML. I tried adding 'lang' => 'all' as an argument to WP_Query parameters but did not get a positive result.
Note that if a user creates the custom post type it will have a post_status pending. WP_Query is used to retrieve an overview of all custom posts with this status.

Symptoms:
When performing a WP_Query for the custom post type, only records in the default language are shown, and records in other languages, like Dutch, are filtered out.

Questions:
How can I modify WP_Query to include custom post types in all languages?
Is there a specific WPML setting that needs to be adjusted to display custom post types in non-default languages?

July 16, 2025 at 4:55 pm #17243099

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for contacting WPML support.

If you want to retrieve posts from all languages, you need to use the suppress_filters argument in your query.
• Set suppress_filters = true to fetch posts from all languages.
• Set suppress_filters = false to get posts only in the currently viewed language.

You can find more information here:
https://wpml.org/documentation/support/achieving-wpml-compatibility-for-your-themes-and-plugins/#filter-correct-ids