Skip Navigation

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

Problem:
The client was experiencing an issue where posts were not displaying unless one post was translated, even though the WPML settings were set to 'Translatable - use translation if available or fallback to default language'. The posts were sorted by a custom taxonomy and needed to be visible in the Spanish translation without being translated, as they linked to primarily English content.

Solution:
We resolved the issue by adding the parameter

'hide_empty' => false

to the

get_terms()

function in the custom WP_Query. This allowed terms with no posts translated into the secondary language to be displayed.

$terms = get_terms(array(
    'taxonomy' => $taxonomy_slug,
    'child_of' => $parent_term_id, // Specify the parent term ID
    'hide_empty' => false
));

If you're experiencing a similar issue, we recommend trying this solution. However, please note that this solution might be irrelevant if it's outdated or not applicable to your case. We highly recommend checking related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket with us.

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 16 replies, has 2 voices.

Last updated by Long Nguyen 8 months, 3 weeks ago.

Assisted by: Long Nguyen.

Author Posts
March 12, 2024 at 8:47 am #15398099

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I fix the issue on your site by adding the parameter 'hide_empty' => false to the get_terms() function

$terms = get_terms(array(
    'taxonomy' => $taxonomy_slug,
    'child_of' => $parent_term_id, // Specify the parent term ID
	'hide_empty' => false
));

Looking forward to your reply.
Thanks

March 12, 2024 at 5:54 pm #15401008

kurtK-7

Thank you for sticking with this. Your solution was successful. 'hide_empty' => false

March 13, 2024 at 1:23 am #15401845

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Thanks for your confirmation.
Feel free to open another ticket if you have any questions. Have a good day!