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 2 voices.

Last updated by Bruno Kos 1 month, 2 weeks ago.

Assigned support staff: Bruno Kos.

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

georgiS-3

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
Supporter

Languages: English (English )

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

Hi,

I moved this chat into professional ticket because there was no response. Can you tell me if you tried to the following?
https://wpml.org/forums/topic/echo-the-number-of-post-under-taxonomy-in-different-lang/#post-1310841

Regards,
Bruno Kos