I have got taxonomy “catalog” where I have custom field “producer” which is from to other taxonomy. In producer page I would like to show all catalogs which are assigned to this producer. Same thing I would like to do in “category” taxonomy. I’m not sure that I explained it clearly, so I tried to create a schema. Thanks…
https://imgur.com/xfLvP1I
What you want to do is very similar to this https://www.advancedcustomfields.com/resources/querying-relationship-fields/ except that you’d be using querying “catalog” based on the taxonomy field and using the term ID value instead of the post ID value.
$args = array(
'taxonomy' => 'catalog',
'meta_query' => array(
array(
'key' => 'producer'
'value' => '"'.$term_id.'"',
'compare' => 'LIKE'
)
)
);
get_terms($args);
What you want to do is very similar to this https://www.advancedcustomfields.com/resources/querying-relationship-fields 8 ball pool except that you’d be using querying “catalog” based on the taxonomy field and using the term ID value instead of the post ID value.
I did everything, thanks for help.
Thank you @hube2 and @kimclarke it works fine, but… I can’t see customes fileds I see only defaults:
Array
(
[0] => WP_Term Object
(
[term_id] => 655
[name] => Adalit
[slug] => adalit
[term_group] => 0
[term_taxonomy_id] => 655
[taxonomy] => katalog
[description] =>
[parent] => 0
[count] => 0
[filter] => raw
[term_order] => 0
)
)
P.S. my taxonomy haven’t got any posts (and it never get them), it’s only taxonomy with customes fields