Choose WordPress Pages Displayed In Navigation Bar
If your blog has a navigation bar in or near the header and you create a lot of pages on your WordPress blog chances are it is getting somewhat cluttered. You can control what pages are displayed by including the ones you want or excluding a certain few. Here is a short WordPress guide to help you clean things up.
Warning before editing any theme files make a backup so you can fix any mistakes!
The first thing to decide is if you are going to include certain pages or exclude certain pages. Each page has an ID number associated with it. To find the page’s ID numbers in the dashboard click Manage, Pages and look for the ID number of the page. Next open your header.php file and look for this code:
<?php wp_list_pages(‘depth=1&title_li=’); ?>
That bit of code is going to display all the pages you create. To exclude certain pages use the below code in its place and add the page ID numbers comma separated. The example below is excluding page ID 6 and 4.
<?php wp_list_pages(‘title_li=&depth=1&exclude=6,4′); ?>
To include only certain pages you can try this next bit of code:
<?php wp_list_pages(‘title_li=&depth=1&include=6,4′); ?>
There are many more parameters to list pages, learn more about WordPress page navigation here: WP List Pages
You can also ‘hard code’ any URL in the WordPress navigation bar as this previous post explains: Specify WordPress Navigation Page Links
Similar Posts:
- WordPress To Run Your Website
- Adding The Sidebar To The WordPress Page Or Single Post Template
- You Can Put Lipstick On A Static HTML Site But It Will Still Not Be A WordPress Site
- Where Are WordPress Stats In Version 2.7
- WordPress 2.5 Dashboard Changes
If you liked this post, feel free to leave a comment that is relevant to the post or subscribe to the feed and get future articles delivered to your feed reader.
Sorry but due to the spamming of a few all comments are moderated and will appear when approved and all drive-by comments will be deleted!












Comments
Good tip Jeff! I have five pages on my nav. Do you think that would be considered cluttered? My thought is to get the “pages” up there above the header, out of the sidebar.
Alex
Reply
Alex you will know when they are cluttered when the pages start to wrap around and you have two rows!
No yours looks fine.
Reply
Great guide. Thanks for solving my problem.
Reply
Hi there,
I was looking how to do this and tried to – I changed the sidebar php via the theme editor, but nothing changed on my site. Does it have anything to do with the theme using widgets?
Reply
Eva This guide is for the navigation in the Header not the sidebar.
If you tried that in the sidebar and you are using widgets, then (usually depending on the theme) the widgets will override the code for pages in the sidebar files. As soon as you drag a widget into the sidebar it will stop showing the default or hard coded sidebar items.
To exclude pages in the sidebar go to the Pages sidebar widget (Presentation, Widgets) click the pages widget to open it and choose what page ID to exclude.
Reply
Thanks for the quick reply, Jeff. I haven’t done much with widgets, and the only thing I seem to be able to change is the title of the “Pages” widget. It doesn’t give me any option to enter/exclude anything else.
Reply
Eva you are running WordPress 2.0.4, that is probably why. I don’t know exactly when/what version that option was available but perhaps an upgrade is in order?
Reply
I prefer to keep the advertising on my blog to a minimum. I just use a few banners for related products and a subscription form for my list. I prefer not to use Adsense or any other similar services. A cluttered blog can overwhelm visitors and stop them from reading.
Reply
Useful article, thank you + it helped out on my site!
Reply
[...] to large and cluttering up your sites top navigation or Pages sidebar widget check out this post: Choose WordPress Pages Displayed In Navigation Bar WordPress Guide Share This Gregarious FeedFlareIf you’re new here, you may want to [...]
Thanks Jeff, that was what I was looking for – the explanation on WP site – http://codex.wordpress.org/wp_list_pages – did not have what you so quickly provided. Thanks.
Reply
Hi Jeff,
I just did it and the navigation bar now looks very neat for once.Thanks also for reminding about backing-up the header theme file first before doing so. It saved my life. For about 10 minutes my world came tumbling down. I must have made a mistake in the code and my blog returned a total blank page. Thank God I had the back-up and re-do the steps you mentioned, the second time doing it more carefully. Thanks to you and your post.
Peter Lee
Work From Home Business Blog.
Reply
Hello,
Thank you very much for your tutorial. It was exactly what I was looking for.
Thanks again.
Regards,
Nicholas
Reply
Hi Jeff,
Am doing some research on header navigation and I keep coming to your pages.
Is it possible to display alternate header navigation based on characteristics of the page/post being displayed? For example, I’d like to display one version of the header navigation if the page/post is public, another header navigation if the page/post is private.
Thanks for your post and advice,
Daniel
Reply
Jeff Replied:
May 8th, 2009 at 12:11 pm
Daniel there is probably a way to do that but I don’t know how. What you want to research is a WordPress template tag “If” statement or a Conditional tag.
More on the Conditional tag there:
http://codex.wordpress.org/Conditional_Tags
Reply
Daniel Noll Replied:
May 11th, 2009 at 12:34 pm
Jeff,
Thanks for the follow-up.
It is possible to do this. I solved it with an if…then statement in header.php that queried a table created by the User Access Manager plugin based on the post_id. Pretty straightforward once I found the table, and the correct syntax.
Daniel
Reply
Sorry Jeff, Just realised I did not put on my website address. The two blog categoires I want to remove are Customer Comments and FAQ. At the moment I have deleted the categories and what you see on my sidebar are links.
Thanks
Dave
Reply
Jeff Replied:
May 11th, 2009 at 7:39 am
Dave I didn’t respond earlier because your question has nothing to do with the post. Yes there is a way to edit a theme and show only specific categories but the explanation isn’t real short and simple. This is not a forum or a WordPress support site.
Check out: http://wordpress.org/support/ Also look into the link I referred Daniel to in the above comment about Conditional Tags.
Reply
Leave a comment
Drive-By comments will be deleted! Like "Thanks for sharing", "Nice post", or any other text that doesn't contribute to the discussion. If you ask a very specific question about your particular WordPress theme, it will probably be deleted. I can fix your WordPress site but for a price. If you ask a question like "Why don't my blog work right", it will be deleted. If you ask a question about your WordPress site without a leaving a link to it, it will be deleted. The point is to ask questions and or comment on the the actual content of the post, and to please use some common sense. All comments are moderated and will appear when approved. Thank you.