Querying posts globally based on custom taxonomy with its own taxonomymeta table

For those running into issues in the future, this is what I did: I made my pre_get_posts function that queries the taxonomy as normal for testing if an taxonomy ID is not in a list: $q->set( ‘tax_query’, array(array( ‘taxonomy’ => ‘tax’, ‘field’ => ‘id’, ‘terms’ => tax_get_inactive(), ‘operator’ => ‘NOT IN’ ))); Then, I implemented … Read more

Complex Taxonomy scheme

Set your system up like this: locations – CPT administrative – hierarchical taxonomy natural – hierarchical taxonomy type – non-hierarchical taxonomy In the administrative taxonomy, you would create your tree: countries on the first level, regions second, departments and so on. Then, you would assign your locations to the smallest administrative denominations among your taxonomies … Read more

wp_get_object_terms count on taxonomies within an category archive

A simple function to count posts did the trick, but this is one more request in DB : function count_posts_in_cat_by_custom_term( $category_ID, $custom_taxonomy_name, $custom_term_id ){ $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘category’ => $category_ID, ‘tax_query’ => [ [ ‘taxonomy’ => $custom_taxonomy_name, ‘fields’=>’term_id’, ‘terms’ => $custom_term_id, ] ] ); $posts = … Read more