I have a custom taxonomy, and as navigation, on archive pages, I list all the children of a specific parent. I achieve it with this –
`<?php`
`$term_id = get_queried_object()->term_id;`
`$parent = get_queried_object()->parent;`
`$term = get_term($parent, ‘cars’ );`
`$args = array(`
`’orderby’ => ‘name’,`
`’order’ => ‘ASC’,`
`’hide_empty’ => true,`
`’child_of’ => $term->term_id,`
`’parent’ => $term->term_id,`
`);`
`$sub_terms = get_terms( ‘cars’, $args);`
`foreach ($sub_terms as $term) { ?>`
`<a type=”button” class=”btn btn-gcard me-2 mb-2″ href=”<?php echo get_term_link( $term ); ?>”><?php echo $term->name; ?></a>`
`<?php } ?>`
Now, every post within these custom taxonomies is also tagged (standard WordPress tags) either with “SUV” or “Coupe”, and my question is – could I somehow modify the above code to show only taxonomies that contain posts tagged with “SUV”?
So instead of having: Audi Cars (a6) (a8) (r8)
I would have something like : Audi SUVs (a6) (a8) Audi Coupes: (r8)
I know I can achieve this by adding another level of hierarchy to the taxonomy, but it’s too late for that.
[ad_2]