Way to Drill down through child categories
-
I am creating a store for tshirts I list on Amazon. I have a page that displays the children of category 15 with a custom template… some of those categories has children… right now, when you click on one of them it takes you to a page with a custom theme that displays all the tshirts (posts) in that category… my goal is, that when you click on a category that has childern categories, instead of getting the page with posts I want a page with the children categories… so you can drill down through the children..
Something like this:Loop
If Cat has children
Link to page that lists children categories
Else
Link to page that displays posts in that category
End else
End loopHere is the code of the current page that shows the categories:
———-
<?php /* Template Name: Show Cat Page */ ?>
<?php
get_header(); ?>
<?php get_sidebar(‘top’);
echo ‘<div id=”category-row”>’;
$args = array(
‘parent’ => 15,
‘hide_empty’ => 0
);foreach( get_categories( $args ) as $category) {
if ( $category->term_id <> 15) { // hides ‘t-shirt category
echo ‘<div class=”outer-category-container”>’;
echo ‘<div class=”store-category-container”>’;
echo ‘slug . ‘”>’;
echo do_shortcode(sprintf(‘[wp_custom_image_category term_id=”%s”]’,$category->term_id));
echo ‘<div class=”store-category-title”>’. $category->cat_name . ‘</div>‘;
echo ‘</span>’;
echo ‘</div>’;
echo ‘</div>’;$index++;
if ($index % 5 == 0) {
echo ‘</div><div id=”category-row”>’;
}
}
}
echo ‘</div>’;
get_sidebar(‘bottom’); ?>
<?php get_footer(); ?>
———-Any help would he appreciated.
SteveThe page I need help with: [log in to see the link]
- The topic ‘Way to Drill down through child categories’ is closed to new replies.