The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WP help: exclude a specific page’s children from nav

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #32872

    My nav is currently generated by:

    This lists all the top-level pages and all direct children of those pages.
    One of my top-level pages has around 18 direct children, and I’m wondering if there’s a way to tell the exclude parameter to simply exclude all children of this one top-level page, rather than hard code a list all 18 pages for the exclude.
    I tried something like:

    49 being the page # of the top-level parent w/the 18 children. But this removed the top-level page from the nav.



    It can be easily done and your not far off all you need to do is get the page id’s as the id of the page in the database not the div id. You can find the idea of page by clicking on pages and hovering over those pages and the id will be at the end of the url. You then use the exclude bit and place in comma separated id’s. The other ways are using exclude tree which gets rid of parent and hiding them with css but you should really use the first way.

    Here is the function reference which shows you how to do this:
    Your text to link…

    Hope this helps!


    49 is the page id, I think my using of # in the context I did to mean number as opposed to id was misleading.
    Saying ‘exclude=49’ is not what I want though, 49 has a bunch of children pages, and I want to exclude those while keeping 49, and my thinking is I can exclude them by creating a variable that targets all of them, as opposed to doing ‘exclude=14,67,45,34,etc..’ in the event that additional children pages are created later this would prevent having to go back in and add those pages to the php.


    You may try these plugins
    yet I’m not sure they will work for you.


    you can just exclude the children pages all you have to do is get their id not the parent and yes you can save them into a variable if you wish!


    As an easier way of identifying id numbers for post, pages, etc, try the Reveal IDs plugin — it shows the id numbers (post, pages, categories, you name it) in the Dashboard interface. Invaluable for building loops easily.


    Could you instead list only the top level pages and then when on that page, you could include the menu for subpages?

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.