I have a custom post type called "Products" and it has a "Product Categories" taxonomy that has categories Category 1, Category 2, etc., which again has subcategories Category 1a, Category 2a, etc. I want, when I click on category 1, it should list the subcategories Category 1a, Category 2a, etc. When you click on category 2a, it should display the products associated with the category. How to do it with wordpress?
<?php $taxonomy_name = 'al_product_cat'; $term_childs = get_term_children( $wp_query->get_queried_object_id(), $taxonomy_name ); <div class="tax_content"> <div class="feat_thumb"></div> <div class="feat_content"> <h2><a href="<?php echo get_term_link( $child, $taxonomy_name ); ?>"><?php echo $tm->name; ?></a></h2> <p><?php echo $tm->description; ?> </p> <div class="brand_logos"> <?php $terms = get_the_terms( $wp_query->get_queried_object_id(), 'brand' ); foreach($terms as $term){ ?> <img src="<?php echo z_taxonomy_image_url($term->term_id); ?>" /> <?php } ?> </div> </div> <div class="clear"></div> </div> <?php } ?>
source share