I have a CPT with the following taxonomies: category, taxonomy_1 and taxonomy_2 (the last two are non-hierarchical).
I want to get programmatically all the terms of the "category" taxonomy but only of the posts with a given meta value — that meta value is storing the ID of another taxonomy (taxonomy_2
).
So it would be: Categories -> Posts -> Specific meta value
I've tried the following without success:
$args = array(
'meta_query' => array(
'key' => 'taxonomy_key_in_CPT',
'value' => 'value_of_taxonomy_key_in_CPT',
'compare' => "=",
)
)
$categories = get_categories( $args );
But this will still return all the categories under the CPT. Am I doing something funny?