WP help: exclude a specific page’s children from nav
# May 25, 2011 at 5:40 pm
My nav is currently generated by:
< ?php wp_list_pages("title_li=&depth=2"); ?>
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:
< ?php $exclude = 'child_of=49';?>
< ?php wp_list_pages("exclude=$exclude&title_li=&depth=2"); ?>
49 being the page # of the top-level parent w/the 18 children. But this removed the top-level page from the nav.# May 26, 2011 at 12:53 am
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!# May 26, 2011 at 2:07 am
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.# May 26, 2011 at 5:00 am
You may try these plugins
yet I’m not sure they will work for you.
You must be logged in to reply to this topic.