Jump to content
Sign in to follow this  
techstuff

iBlogPro 3 - Categories as Navbar links

Recommended Posts

techstuff

How can I make Categories appear as page links in the navbar? I thought this was in the theme options but I don't see it.

Share this post


Link to post
Share on other sites
Andrew

I usually recommend people use the LJ Custom Menulinks plugin for nav item tweaks. I might have to look closer at this because its an often requested feature. WP doesn't make it easy to mix pages and category links (different function calls wp_list_pages and wp_list_categories)

Share this post


Link to post
Share on other sites
slesage

Hi, I actually wanted to do something similar as well, and was able to achieve it with just a slight modification in the _nav.php

	<div id="nav" class="fix">
		<ul class="fix">
				<li class="page_item navfirst">/" title="Home">/images/home-icon-trans.png" alt=""/>
			<?php
				$frontpage_id = get_option('page_on_front');
				/* sLesage : We want to get our Blog Page first, then the Podcast Category page, then all others */
				$blogpage_id = get_option('page_for_posts');
				wp_list_pages('sort_column=menu_order&include='.$blogpage_id.'&depth=1&title_li=');
				wp_list_categories('include=116&title_li=');
				wp_list_pages('sort_column=menu_order&exclude='.$blogpage_id.','.$frontpage_id.',260&depth=1&title_li=');
				/* sLesage : Finished custom coding here */
				/* Original Code
				wp_list_pages('sort_column=menu_order&exclude='.$frontpage_id.'&depth=1&title_li=');
				*/
			?>
	
		<?php include (TEMPLATEPATH . '/searchform.php'); ?>
	</div><!-- /nav -->
	[/code]

	
	If you take a closer look at the code, you'll see I added 3 lines of code (replacing the original one which I left in comments).  The call to
	
	
[code] wp_list_categories('include=116&title_li=');
Is what you actually needed. In my case I only wanted one category to appear, so I added the ID of that category in the Include parameter. In my example, I wanted my Blog posts page to appear first, then my category and after that all other pages (except the front page which is the Featured Page).
$blogpage_id = get_option('page_for_posts');
	wp_list_pages('sort_column=menu_order&include='.$blogpage_id.'&depth=1&title_li=');
	
This code is used to get the ID of the Blog page, and display it as the first item in the Navigation Bar.
wp_list_categories('include=116&title_li=');
This lists the categories (in my case only the one I was interested in).
$frontpage_id = get_option('page_on_front');
	wp_list_pages('sort_column=menu_order&exclude='.$blogpage_id.','.$frontpage_id.',260&depth=1&title_li=');
	

And this last piece of code displays all pages (except for the Blog Page since we already have that one, and the Featured Page since we don't want to show that one. Hope this is of any use to you. Regards, Stefaan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×