same taxonomy for several post types: how to hide empty in a specific post type?

Thanks to this answer, I was able to see the light. Here is how to query taxonomy terms related to (woocommerce) products that are “in stock”. It uses both tax_query (to relate product to taxonomy) and meta_query (to filter out out-of-stock products). $artists = get_terms_by_post_type( array(‘artist’), array(‘product’)); if( !empty($artists) && !is_wp_error( $artists ) ){ // … Read more

Exclude Child Terms From Parent Posts

In your get_terms() call, try setting the hierarchical option to false: $children_terms = get_terms($taxonomy, array( ‘parent’ => get_term_by(‘slug’, $parent_term, $taxonomy)->term_id, ‘hierarchical’ => false )); This option normally defaults to true, which is probably why you’re getting the extra copies.

Child terms from multiple parents?

We can filter the generated SQL query through the terms_clauses filter before the SQL query is executed. What we will be doing is to introduce a new parameter called wpse_parents which will accept an array of parent term ID’s to get children from. Note, this new parameter works exactly the same as the build-in parameter, … Read more

wp_list_categories: order by term order?

The wp_list_categories() function calls the get_categories() function, that’s a wrapper for the get_terms() function, that creates an instance of the WP_Term_Query class. It doesn’t look like it supports ordering by term order. If the plugin uses the term_order column in the wp_terms table, then you can try to add a support for it’s ordering, via … Read more