if a user clicks on a category, that leads him to a category archive page, done with category.php
right at the start of that template, you can check if the current catgory has a parent or children, and dependant on that, you can show the list of sub-categories or posts.
this might be useful:
$the_active_cat_ID = get_query_var('cat');
http://codex.wordpress.org/Function_Reference/get_category
http://codex.wordpress.org/Function_Reference/get_categories
http://codex.wordpress.org/Template_Tags/wp_list_categories
Thanks for the prompt reply. I am not much of a coder so I am finding the dots a little too far apart to connect. It seems I need to add code to category.php
I see the examples of arguments, but I am not sure how to use the code to get my sub category names to display in place of sub cat posts.
I appreciate any further “dumbed down” guidance.
Thanks again.
what theme are you using right now?
to allow the suggestions to match your existing structure, please paste the full code of category.php into a pastebin and post the link to it here – ( http://codex.wordpress.org/Forum_Welcome#Posting_Code )
Theme=Coraline
category.php is-
http://pastebin.com/6wkysMVd
http://pastebin.com/R2fvgrHx
this section is new:
//show a list of direct child (sub) categories if available//
if( $list = wp_list_categories('echo=0&title_li=&show_option_none=&depth=1&child_of='.get_query_var('cat')) ) {
echo '<h3 class="sub-categories-title">Sub Categories List</h3>';
echo '<ul class="sub-categories">' . $list . '</ul>';
}
//tweak the query to show only posts direct in the current category//
global $wp_query;
$args = array_merge( $wp_query->query_vars, array( 'category__in' => array(get_query_var('cat')) ) );
query_posts( $args );
the first part checks if there are direct children (sub-categories) of the current category, then output the list.
the second part changes the query to show only posts which are in the direct category (normally the category archive will also show posts which are in sub categories of the current category).
new introduced css classes for better formatting:
.sub-categories
.sub-categories-title
Boy did that work perfect!
Thank you so much for awsome support!