Few days back, I shared a wordpress trick on How to Add categories to Nav Bar. Today, i wan to share one more Wordpress Trick.
If you look at the Header section of this blog, you will see the Nav Bar. It includes pages and also some categories.
![]()
You can see from the above, that i have included following 3 pages along with the some categories. Also notice that they are not one after the other in serial order:
How do you do this?
It is pretty simple. You need to have some knowledge in Wordpress and you should find out in which theme file your Nav Bar code is residing.
Instructions to Add Pages to Nav Bar
My theme has nav_menu.php file. This file contains the menu code. I have put the following code in this file:
<?php wp_list_pages('include=9&title_li='); ?>
<?php wp_list_categories('orderby=name&include=3,25,42,11,10&title_li='); ?>
<?php wp_list_pages('include=225,23&sort_column=menu_order&title_li='); ?>
You can see from the above code, I have am making two calls to wp_list_pages function and in between wp_list_categories. This is the reason you see the pages and categories are mixed in the Nav Bar.
I have specified the pages that i want to include using “include=225,23″ parameter.
Each Page is assigned with a Page ID. To find the Page ID, just go to Pages -> Edit and hover over the title of any Page. The status bar of your browser will display a URL with a numeric ID at the end. This is the Post ID. You can see from the below url: 23 is the Page ID.
http://www.niharsworld.com/wp-admin/page.php?action=edit&post=23
One important thing to notice about wp_list_pages function is that the Pages are sorted alphabetically by Page title. But, if you want them to be in another order then use sort_column=menu_order parameter.
For each Page, you can assign the Page Order from Write > Page administrative panel.
For ex: If I want Contact me to appear at the end. I will assign a higher number to Contact Me than other two pages I am displaying.
![]()
wp_list_pages function generates each page as list <li>..<li/>. It marks the current Page with HTML class current_page_item.
For more instructions on wp_list_pages and Styling of Category List, Please check wp list pages.
Please leave a suggestion or doubts if any by leaving a comment
Technorati Tags: add page, How-To, nav bar, TipsNTricks, Wordpress, Wordpress Page
|
1921 readers are already subscribed to this blog! Why don't you be one of them? Subscribe to this blog via your favorite RSS feed reader or by entering your email address on the form below: |
You Should Also Check Out These Posts:
- How to Add categories to Nav Bar
- How to Remove Wordpress Meta Generator tag
- Broken Links Remover – A must Wordpress Plugin
- Blog slowed down after upgrading to Wordpress 2.8
- Increase Blogs internal linking using SEO Smart Links Plugin


Subscribe
In your last post on this subject I was wondering how you managed to combine the pages with the categories, now I know, thanks.
Lyndis last blog post..Free WordPress Themes and their users
I’m not aware of it. Now, I know what to do to combine my category pages to the main menus. Is it works for drop down menus?
Atnizs last blog post..The Problem Working At Home
@Atniz, I am not so sure whether this is the same thing to be used for drop down menus. May be i should also explore and come up with that post in future
Ah! This is waht I was waiting for. I will now change my Navigation Bar. Thnx mama!
Read 2 Knows last blog post..Live Streaming links of Swearing-In of Barack Obama
@Arun mama, Have you implemented it on your blog?
Adding categories is great nihar..I searched for this longback and left without luck.
Thanks dude for this useful info.
TechZoomIns last blog post..5 Simple “Read More/Continue Reading” Tag Design Styles
@TechZoomIn, I hope you add it. I liked your post that is listed here.
Thanks a lot Nihar for this useful tip. I was looking for this information for a long time.
@Roger, I hope this works for you.
[...] How to Add Wordpress pages to Nav Bar [...]
I hope we can be get good advantage with the help of this tip.
@Toronto personal injury, I am happy that this tip helped you.
[...] How to Add Wordpress pages to Nav Bar [...]