Different templates for parent and children Taxonomy

The {$type}_template_hierarchy filter can be used to add templates to the list of files to check for each request: Filters the list of template filenames that are searched for when retrieving a template to use. With this filter, you can do something like below: add to theme’s functions.php or an mu-plugin (untested): add_filter( ‘taxonomy_template_hierarchy’, static … Read more

Two related taxonomies. how to filter terms in second taxonomy depending on selected term in first taxonomy on Post edit page?

My approach would be: Hide city edition metabox, by setting public to false. I would override how metabox for country should render by using meta_box_cb parameter. You should provide callback for the function that will do the render. In this function, you first render the field for country, and then on choose you make an … Read more

Searching in categories AND custom fields

Adding the tax_query parameter to the $args array with the proper arguments will check for the category as well (untested): $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 15, ‘paged’ => $paged, ‘meta_query’ => array( array( ‘key’ => ‘meta_easyfatt_libero_1’, ‘value’ => ‘Men’, ‘compare’ => ‘LIKE’, ), ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ … Read more

Showing all posts of the current custom taxonomy on archive page

I have finally found a solution and for anyone interested, here is the working code : <?php // The Query if (is_tax() || is_category() || is_tag() ){ $qobj = $wp_query->get_queried_object(); // concatenate the query $args = array( ‘post_type’ => ‘houses’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => … Read more

Operator ‘AND’ in the get_posts() function’s tax_query terms not working

Try adding include_children parameter as false to your first example (tested): $args = array( ‘post_type’ => ‘workshops’, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘workshop_categories’, ‘field’ => ‘slug’, ‘terms’ => array( ‘crafts’, ‘jewellery’ ), ‘operator’ => ‘AND’, ‘include_children’ => false, ) ) ); $posts = get_posts( $args ); Unfortunately I … Read more

How to get taxonomy category in permalink for each taxonomy OR How to give a parent page to a given taxonomy?

This worked for me (tested): add_action( ‘init’, static function () { register_taxonomy( ‘portfolio-work’, ‘post’, array( ‘hierarchical’ => true, ‘labels’ => array( ‘name’ => ‘Portfolio Works’, ‘singular_name’ => ‘Portfolio Work’, ), ‘rewrite’ => array( ‘slug’ => ‘work’, ‘with_front’ => false, ), ) ); } ); Then created new pages titled “Blog” (slug: blog) and “Work” (slug: … Read more

Add a Permalink To a Post Title?

Yes, you can output custom fields on the front end. You’ll need to start by creating a child theme. You can then copy whichever file applies – the one you’re showing looks like perhaps an archive.php, category.php, or something similar. Finally, tweak the output so that in addition to (or instead of) the title you’re … Read more