• gravitythedon

    (@gravitythedon)


    Hi,

    I would very much appreciate an experts advice on the question I have as I am new to WordPress.

    I wish to be able to ‘drill down’ through my categories in the main page to get to my articles.

    When I click on a category in the sidebar, I do not want the main page to display any articles, I want it to display the list of sub-categories

    i.e.

    Say I have ‘Music’ as a top level category, ‘Genre’ as a sub-category and then ‘Artist’ as a child of genre.

    I wish to be able to click ‘Music’ in the sidebar, which in turn would display a list of all ‘genres’ in the main page, then when I select a ‘genre’ it will display a list of all ‘artists’ in the main page, and it is not until I finally choose an artist that I want the articles to be displayed.

    Thanks for your time!

    Cheers,
    Grav

Viewing 2 replies - 1 through 2 (of 2 total)
  • MichaelH

    (@michaelh)

    Well if you make this your category.php it will work–at least it does with the WordPress Default theme.

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    
    <?php
    $cat = get_query_var('cat');
    $children = get_category_children( $cat, '', '' );
    if ( $children ) {
    
    wp_list_categories('title_li=Here are the children!&child_of='.$cat);
    } else {
    ?>
    		<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    				<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>
    
    <?php } 	?>
    
    </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
    Thread Starter gravitythedon

    (@gravitythedon)

    Many thanks for taking the time to post the code, I will have a play about and let you know how I get on!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘When category selected show sub-categories as opposed to posts?’ is closed to new replies.