Exclude a term of a taxonomy with a custom post type in a search

The problem with your approach is that woocommerces product category is a custom taxonomy called product_cat. But with cat you are addressing the built-in category. Taxonomies can be addressed with a tax query, simplified example below: function wpse188669_pre_get_posts( $query ) { if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { $query->set( ‘post_type’, array( ‘product’ … Read more

Find callback function for custom taxonomy metabox

The callback you need for non-hierarchical taxonomies is post_tags_meta_box. The callback you need for hierarchical taxonomies is post_categories_meta_box. For your example, the code would be: /* Remove movies metabox from sidepanel */ function hide_metabox(){ remove_meta_box( ‘tagsdiv-movies’, ‘your-post-type’ , ‘side’ ); } add_action( ‘admin_menu’ , ‘hide_metabox’ ); /* Add back movies metabox, but in post area … Read more

Custom taxonomies, with custom rewrites/slug, AND loading a taxonomy archive template from a plugin

Background & Core Functionality Why a Taxonomy Path Slug Alone Produces a 404 However this slug doesnt work. mysite.com/wiki/help-topics throws a 404. WordPress does not provide a mechanism for “an archive of taxonomy terms” out of the box – that is, neither the template hierarchy nor the WP_Query/WP_Tax_Query logic support a direct display of terms … Read more

Get the latest taxonomy/category?

The latest edition should always be the term in that taxonomy with the highest term_id, right? Query get_terms and find the latest edition, then use that term to build the rest of your query… $edition = get_terms(‘edition’,’orderby=none&order=DESC&number=1′); $latest_edition = $edition[0]->slug; Then you can either modify the current query, if that’s what you want to do: … Read more

Exclude from search all custom posts which are NOT in a taxonomy term

After reading your revised question it was easier to comprehend what you are trying to do. My new solution looks like the thing you wanted to do in the first place: it just excludes all posts which are of your custom type but don’t have the “yes”-term associated with it: $custom_query = array(); $custom_query[‘post_type’] = … Read more

Different templates for parent and children categories/taxonomies

I suggest creating 3 files 1) regiontemplate-country.php 2) regiontemplate-city.php These 2 will contain the templates for country & city, then 3) taxonomy-region.php In this file, add the code to load the appropriate template <?php $term = get_term_by(‘slug’, get_query_var(‘term’), ‘region’); if((int)$term->parent) get_template_part(‘regiontemplate’, ‘city’); else get_template_part(‘regiontemplate’, ‘country’);