• Hey there,

    i’m attempting to create a category based navigation that would look something like this:

    Main Nav: Home | Category 1 | Category 2 | Category 3 | Category 4
    Sub nav: Child of Cat 2 | Child of Cat 2 | Child of Cat 2 | Child of Cat 2

    Basically, what I want is to show the children categories of the main categories.

    I’ve been trying to get it running with the wp_list_categories() function, but for some reason, it doesn’t seem to work once you get into archive pages, or single entry pages.
    Here is the code i’m currently working with:

    <div id="upperNav">
    		<div class="navLinks"><a href="<?php bloginfo('url'); ?>"<?php if ( is_home()) { ?> id="active"<? } ?>>Home</a>  <a href="<?php bloginfo('url'); ?>/category/news/"<?php if ( is_category('news')) { ?> id="active"<? } ?>>News</a>  <a href="<?php bloginfo('url'); ?>/category/reviews/"<?php if ( is_category('reviews')) { ?> id="active"<? } ?>>Reviews</a>  <a href="<?php bloginfo('url'); ?>/category/videos/"<?php if ( is_category('videos')) { ?> id="active"<? } ?>>Videos</a>  <a href="<?php bloginfo('url'); ?>/category/features/"<?php if ( is_category('features')) { ?> id="active"<? } ?>>Features</a>  <a href="<?php bloginfo('url'); ?>/category/games/"<?php if ( is_category('games')) { ?> id="active"<? } ?>>Games</a>  <a href="<?php bloginfo('url'); ?>/shop/"<?php if ( is_category('shop')) { ?> id="active"<? } ?>>Shop</a></div>
    		<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    		<div class="clearMe"></div>
    	</div>
    	<ul id="lowerNav" class="sf-menu">
    			<?php if ( is_home() || is_category('news')) {
    					$catVar = $newsCategoryVar; ## Show only if in NEWS category or home page
    				} elseif ( is_category('reviews')) {
    					$catVar = $reviewsCategoryVar; ## Show only if in REVIEWS category
    				} elseif ( is_category('videos')) {
    					$catVar = $videosCategoryVar; ## Show only if in VIDEOS category
    				} elseif ( is_category('features')) {
    					$catVar = $featuresCategoryVar; ## Show only if in FEATRUES category
    				} elseif ( is_category('games')) {
    					$catVar = $gamesCategoryVar; ## Show only if in GAMES category
    			};
    			if (isset($catVar)) {
    				## echo 'You are viewing the children of the ' . $catVar . ' Category';
    				wp_list_categories('child_of=' . $catVar . '&current_category=' . $catVar . '&hierarchical=1&title_li=0&depth=1&hide_empty=1');
    			} ?>
    	</ul>

    Any help would be greatly appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Category based navigation’ is closed to new replies.