• Blogging
  • Freebies
  • Freeware
  • How-To
  • Make Money Online
  • Mobile
  • Home >> Freebies >> How to Add WordPress pages to Nav Bar

    How to Add WordPress pages to Nav Bar


    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.

    Categories in Nav Bar

    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.

    Categories in Nav Bar

    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

    IMPORTANT: This blog welcomes Guest Bloggers, Writers to also contribute by writing Guest Posts and also Make Money!. Check out our Revenue Sharing Program
    1924 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:





    11 Comments

    1. Lyndi says:

      In your last post on this subject I was wondering how you managed to combine the pages with the categories, now I know, thanks.

    2. Atniz says:

      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?

    3. Read 2 Know says:

      Ah! This is waht I was waiting for. I will now change my Navigation Bar. Thnx mama! 🙂

    4. TechZoomIn says:

      Adding categories is great nihar..I searched for this longback and left without luck.

      Thanks dude for this useful info.

    5. Roger says:

      Thanks a lot Nihar for this useful tip. I was looking for this information for a long time.

    6. I hope we can be get good advantage with the help of this tip.

    7. Nihar says:

      @Toronto personal injury, I am happy that this tip helped you.

    Leave a Reply

    page counter
    NiharsWorld on Twitter NiharsWorld on Facebook NiharsWorld RSS Feed