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.

Our next available supporter will start replying to tickets in about 2.03 hours from now. Thank you for your understanding.


This topic contains 1 reply, has 2 voices.

Last updated by Bruno Kos 9 months, 1 week ago.

Assigned support staff: Bruno Kos.

Author Posts
August 27, 2019 at 8:14 am #4463583


I am trying to:
I have this piece of code:

foreach($service_categories as $category) {
	$args = [
		'post_type' => 'listings',
		'numberposts' => -1,			
		'tax_query' => [
				'taxonomy' => 'service_categories',
				'field' => 'slug',
				'terms' => [$category->slug],

$p = get_posts($args);
echo count($p);

This way I'm trying to get the number of posts per this taxonomy. It works great on the main language, but on the second language(English) it shows 0 despite the slugs for category being the same.

Link to a page where the issue can be seen:
hidden link
I expected to see:
Listings for all languages that match the slug of the category
Instead, I got:
0, if I remove the tax query, then I get all posts for all languages as expected. Then iterating through them(and running wp_get_post_terms) I confirmed that they have the expected terms. tax_query does not work though.

August 27, 2019 at 9:06 am #4464077

Bruno Kos

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)


I moved this chat into professional ticket because there was no response. Can you tell me if you tried to the following?

Bruno Kos