What's the best way, to return taxonomies, but only taxonomies that are linked to a product, within the category, I have a heirachial taxonomy, I want to get all the top level options, once an option is picked, I want to get all the children, but only the children that are linked to a product.
Is this possible?
Currently I'm just getting the immediate children of the first term picked, I don't know how to filter out the ones that have no matches.
This is the second request:
$terms = get_terms( 'tyre', array(
'orderby' => 'name',
'child_of' => $term_id,
'hide_empty' => $hide_empty
));
Is there a way to extend this to something like this:
$terms = get_terms( 'tyre', array(
'orderby' => 'name',
'category' => 'tyres',
'only_linked_to_products' => true,
'child_of' => $term_id,
'hide_empty' => $hide_empty
));
Obviously I've just invented these two properties, but it would help illustrate what I'm trying to do
hide_empty
totrue
will - as the name suggests - only return terms that are assigned to a post.