Taxonomy URL Rewrite
Taxonomy URL Rewrite
Taxonomy URL Rewrite
Presumably that would be in your taxonomy-business-location.php template file then. Here’s what the main content area could look like in such a template, basically: <div id=”main-content”> <?php $business_location = get_queried_object(); echo “<h1 class=”business-location-title”>Businesses in ” . $business_location->name . “:</h1><hr>”; // Location A, according to your example $business_categories = get_terms( [ ‘taxonomy’ => ‘business-category’, ‘hide_empty’ => … Read more
I managed to answer this question myself by adding get_queried_object()->term_id; instead of the taxonomy terms ID. It now outputs all the grandchild taxonomy terms for the current taxonomy term. Here is my updated working code: $term_id = get_queried_object()->term_id; $taxonomy_name=”product_range”; $term_children = get_term_children( $term_id, $taxonomy_name ); echo ‘<ul>’; foreach ( $term_children as $child ) { $term … Read more
Try get_ancestors(): $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); $ancestors = get_ancestors( $term->term_id, ‘product_range’, ‘taxonomy’ ); $hierarchy_levels = count( $ancestors ); switch ( $hierarchy_levels ) { case 0: // THIS IS THE PARENT CATEGORY // DO YOUR STUFF break; case 1: // THIS IS THE PARENT CATEGORY // DO YOUR STUFF … Read more
I think you can simply use WP_Term‘s $count property which should hold the number of posts attached to this current term.Then, if only one post is attached to this term, query this post object and do your stuff with it… $term = get_queried_object(); if ( $term->count === 1 ) { $args = array( ‘tax_query’ => … Read more
If you have only 4 level, and each third level term has children, the we can determine the fourth level term if have children: $term_id = get_queried_object()->term_id; $taxonomy_name=”product_range”; $custom_terms = get_term_children( $term_id, $taxonomy_name ); foreach ( $custom_terms as $custom_term ) { $term = get_term_by( ‘id’, $custom_term, $taxonomy_name ); $terms_chilren = get_term_children( $term_id, $taxonomy_name ); wp_reset_query(); … Read more
$term isn’t being set anywhere in your code. You’re putting IDs into $terms_ids, but then in your query you’re using $term->term_id. $term doesn’t exist outside of the foreach. You need to be passing $terms_ids directly into terms: $terms = get_the_terms( get_the_ID(), ‘kosmetyki_dystrybutor’); $terms_ids = []; foreach ( $terms as $term ) { $terms_ids[] = $term->term_id; … Read more
I think if you change the rewrite in your register_taxonomy $args ‘rewrite’ => array( ‘slug’ => ‘photographies/couleurs’,’with_front’ => false ), This will probably clash with rewriting the custom post type so you’ll more than likely get a 404 on this url: http://thewebsite/photographies/ but if you don’t need that url then this solution will help you … Read more
You can use ‘post_type’ => ‘any’ if you are not sure of the post types resulting from other query arguments. According to documentation that is what happens by default when you use tax_query: post_type (string / array) – use post types. Retrieves posts by Post Types, default value is ‘post’. If ‘tax_query’ is set for … Read more
Create archive page for woocommerce attribute