Categories as navigation
-
I want to use my categories as my navigation.
I’ve worked out how to do this manually, by editing the ‘navbar’ in header.php, but whenever i create a new category, i have to manually edit the navbar.Can someone help me how to do this properly?
Thanks!
-
Category Based Navigation
<ul id="menu"> <li <?php if(is_home()) { ?> class="current-cat"< ?php } ?>> <a>">Home</a> < ?php wp_list_categories('title_li=&orderby=id'); ?>
Where do i put that exactly?
Here’s is a snippet from navbar:<div id="navbar"> <ul class="ot-menu"> <li<?php if (is_home()) { echo " class=\"current_page_item\""; }?>><a href="<?php echo get_settings('home'); ?>"><?php _e("Home", 'structuretheme'); ?></a></li> <?php wp_list_pages('title_li=&depth=4&sort_column=menu_order'); ?> </ul> </div>
When i pasted the code you provided into Dreamweaver CS5, i got a syntax error. I had ago myself with the code you wrote and got it to work.
Here’s what my code looks like now:
<div id="navbar"> <ul class="ot-menu"> <li<?php if (is_home()) { echo " class=\"current_cat\""; }?>><a href="<?php echo get_settings('home'); ?>"><?php _e("Home", 'structuretheme'); ?></a></li> <?php wp_list_categories('title_li=&depth=4&sort_column=menu_order'); ?> </ul> <div style="clear:both;"></div> <ul id="menu"> <li <?php if(is_home()) { ?> class="current-cat"<?php } ?>> </div>
It looks a bit messy now! If you could help me make it a bit neater, that’d be great! Most importantly, the code is now working (see http://schristian.eu).
Thanks for your help Woodent!
I cleaned up your code a bit:
<div id="navbar"> <ul class="ot-menu"> <li<?php if (is_home()) { echo ' class="current_cat"'; }?>> <a href="<?php echo get_settings('home'); ?>"> <?php _e("Home", 'structuretheme'); ?> </a> </li> <?php wp_list_categories('title_li=&depth=4&sort_column=menu_order'); ?> </ul> <div style="clear:both;"></div> </div>
The ul with the id of ‘menu’ wasn’t closed out (and wasn’t doing anything), so I removed it.
Have a great day!
- The topic ‘Categories as navigation’ is closed to new replies.