Skip to content Skip to sidebar

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

Problem:
You are trying to retrieve WPML current languages and their flags using specific code, but the queries return null values on a custom post type (CPT) archive page named 'products'.
Solution:
1. Ensure that the 'products' page is translated. This is crucial for WPML to retrieve the correct language data.
2. Change the translation setting for the 'products' post type. Go to WPML-> Settings-> Post Type Translation section, and set it as 'Translatable - use translation if available or fallback to default language'.

If this solution does not resolve your issue or seems outdated, we recommend opening a new support ticket. Also, check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. For further assistance, please visit our support forum at https://wpml.org/forums/forum/english-support/.

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

Last updated by Osama Mersal 9 months, 3 weeks ago.

Assisted by: Osama Mersal.

Author Posts
January 12, 2025 at 8:35 am #16585262

Ido Fishman

Background of the issue:
I am trying to get WPML current languages and their flags using the following code: $languages = apply_filters('wpml_active_languages', NULL); $current_lang = apply_filters('wpml_current_language', NULL);. I have added a CPT named products to my website (I don't run WooCommerce). In WordPress, if you name a page URL exactly like the CPT name, it will make it the archive page. So I added a new page named products (hidden link).

Symptoms:
The WPML queries on the page return null values instead of the expected language data.

Questions:
Why are the WPML queries returning null on the CPT archive page?
How can I get the current languages and their flags to display correctly on the CPT archive page?

January 12, 2025 at 1:28 pm #16585657

Osama Mersal
WPML Supporter since 02/2020

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for contacting WPML forums support. I'll be glad to help you today.

I would need to look closely at your site, so I would need to request temporary access (WP-Admin and FTP)
Preferably to a test site where the problem has been replicated.

Your answer will be private, meaning only you and I can access it.

❌ Please backup your database and website ❌

✙ I need your permission to deactivate and reactivate the plugins and themes and change site configurations. This is also why the backup is critical.

✙ I also need your permission to take a local copy of your site to debug the issue without affecting your live site.

Best regards,
Osama

January 12, 2025 at 3:39 pm #16586040

Ido Fishman

Hey i sent it, please check

January 12, 2025 at 3:46 pm #16586079

Osama Mersal
WPML Supporter since 02/2020

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for the access detail. I checked your site and noticed the following:

1) The hidden link">products page is not translated. Please translate it.

2) The hidden link">products post type is set to "Not Translatable". Please go to WPML-> Settings-> Post Type Translation section, and set it as "Translatable - use translation if available or fallback to default language".

Best regards,
Osama