[resolved] How to seperate pages, some on top nav, all on side nav (3 posts)

  1. christernyc
    Posted 6 years ago #


    I am putting together a blog that has many pages. I only want 5 pages on the top nav, but I want the rest on the sidebar. I've looked everywhere for hacks and tried many plugins to no avail. Now I have to ask for help. Is there a way to to have separate page listings? Or a good hack to put certain pages on the sidebar with a nifty title?

    Basically, I'm looking to form pages on the dashboard and then have the option to put them up top or on the side nav, or both.

    Thanks in advance!

  2. stvwlf
    Posted 6 years ago #

    What you can use is add a parameter to your two wp_list_pages commands.

    In your top nav:

      <?php wp_list_pages('include=5,9,23,16,11&title_li='); ?>

    will include, in that order, only the pages with the ID's 5, 9, 23, 16, and 11

    In your sidebar

      <?php wp_list_pages('exclude=5,9,23,16,11&title_li='); ?>

    excludes all the pages displayed in your top nav. As you add new pages you can add them to either list. If you want a page in both top and side nav, add it to the top list and do not add it to the side list.

    This is a manual process but its simple. If you are not adding pages to Top Nav very often it should work fine.

    One way to automate it would be to add custom fields for IncludeInTopNav and ExcludeFromSideNav, and build the include and exclude lists dynamically using a database query.

  3. christernyc
    Posted 6 years ago #

    Neat, thanks!

    Everyday I learn a little bit more, I appreciate the help.

Topic Closed

This topic has been closed to new replies.

About this Topic