Display hierarchical subterms of custom taxonomy based on depth

I love a good challenge! The function here: function get_post_categories_sorted ( $post_id ){ $terms = wp_get_post_terms( $post_id, ‘category’ ); $sorted_terms = []; foreach( $terms as $term ){ $depth = count( get_ancestors( $term->term_id, ‘category’ ) ); if( ! array_key_exists( $depth, $sorted_terms ) ){ $sorted_terms[$depth] = []; } $sorted_terms[$depth][] = $term; } return $sorted_terms; } will give … Read more

Custom page template for category taxonomy

The hierarchy for custom taxonomies is: taxonomy-$taxonomy-$term.php taxonomy-$taxonomy.php taxonomy.php archive.php index.php So, if your taxonomy was called cats, you could target that specific taxonomy with a template file taxonomy-cats.php. If you wanted to style your tabby cats differently than the rest (because of course you would), then you could use taxonomy-cats-tabby.php. See wphierarchy.com

Get Posts via Taxonomy Term Name with Space

You could get the posts by slug instead of name. Like this: $posts = get_posts(array( ‘post_type’ => ‘coupon’, ‘numberposts’ => -1, ‘post_status’ => array(‘publish’, ‘unreliable’, ‘draft’), ‘tax_query’ => array( array( ‘taxonomy’ => ‘stores’, ‘field’ => ‘slug’, ‘terms’ => array( ‘new-store’ ), ‘include_children’ => false ) ) )); Or you could get the posts by term … Read more

Custom Taxonomy Archive BUG

as mentioned by @mmm you loop over the terms and in each term you loop over each project – however I think this is what you wanted to do: $terms = get_terms( array( ‘taxonomy’ => ‘residential_project_types’, ‘orderby’ => ‘count’, ‘hide_empty’ => true ) ); foreach( $terms as $term ) : ?> <a class=”property-thumb-link” href=”https://wordpress.stackexchange.com/questions/264897/<?php echo … Read more

How To Create A Custom Taxonomy 404 Page

You can filter any type of template to override the template hierarchy. In this case the filter is 404_template. We’ll check if the location query var is set, meaning the URL matched the pattern of a location request, but the result was a 404. In that case, we’ll load the 404-taxonomy-location.php template. function wpd_custom_tax_404( $templates … Read more

Query post from all category with same tag on 1 pages

This will help to get the category post on tag archive page. Let me know. <?php $current_tag = single_tag_title( $prefix = ”, $display = false ); $categories = get_categories( array(‘hide_empty’ => TRUE) ); foreach($categories as $category) { ?> <?php $args=array( ‘posts_per_page’ => -1, ‘tag’ => $current_tag, ‘cat’ => $category->term_id, ); $the_query = new WP_Query( $args … Read more