Unable to exclude page from navigation
-
Hey there.
I can’t seem to exclude certain pages from the main navigation. The links are listed using the wp_list_pages template tag and the parameters are ‘title_li=&depth=1&exclude=14’.
14 being the page ID of the page I wish to exclude. For some reason it’s still sitting in the navigation.
I’ve also tried excluding it using the page widget in the Appearance settings.
Hope someone can help!
Thanks,
Abi
-
Can anyone help with this? Thanks. Abi
If you’re using a child theme, simply edit header.php and modify the wp_list_pages() line with:
wp_list_pages( 'exclude=14' );
I did actually try this and it still doesn’t hide it! And I tried it in the page widget in the Appearance settings!
Hope you can help. Thanks. Abi
What @r-a-y gave you works for me in bp-default child theme. What theme are you using? Do you have any plugin relating to navigation or pages installed in your WP?
Yep I’m using a child theme. It’s bizarre that it doesn’t work.
I have the following plugins activated:
‘Buddypress’
‘Remove BuddyPress Admin Bar’They’re the only ones activated!
Make sure that you’re referencing the right page ID? Also try other page IDs to see if wp_list_pages() is actually working.
Tried hiding a page with a different ID using:
title_li=&depth=1&exclude=2Still doesn’t hide!
Does any one have any ideas? Driving me nuts! Thanks, Abi
The code that people are giving should work. The only way we could test any further is if you posted the code you’re trying to use in context. Are you using a common theme, or one you developed yourself? If the latter, can you put the contents of header.php into a pastebin so others can test it?
I am creating a buddypress child theme.
wp_list_pages should be on line 91. All of that code is within my header.php file.
Thanks,
AbiYou have to add a comma, see below:
exclude=2,'. bp_dtheme_page_on_front()
Ah. As simple as that! Genius. Thanks r-a-y!
Adding to this thread (maybe I should start a new?)…suppose I didn’t want to edit header.php in any way shape or form. Is there any way to suppress certain pages from a functions.php page…
…further what I might actually want to do is suppress *all* wp_list_pages() and just keep the native BuddyPress ones. Hmm…any thoughts?
@arxpoetica – That’s possible via the “wp_list_pages_excludes” filter.
You’ll need to return an array of page IDs you want to exclude.
Example code:
http://pastebin.com/HUyVsWSNChange 1,2,3 to page ids you want to omit.
Thanks @r-a-y — always to the rescue! I’ll let you know if it works.
Here’s what worked for me: http://pastebin.com/WLMckWV6
Again, thanks for the help!
This fix may not work for you, but what I did was I changed the header.php file by commenting out the following line (it was line 79 for me) like so:
Then I manually added new links to my pages:
<li><a href="http://yourwebsite.com/your-first-page/" title='Example Page 1'>Example Page 1</a></li> <li><a href="http://yourwebsite.com/your-second-page/" title='Example Page 2'>Example Page 2</a></li>
It may not be the best way for you, but it definitely works.
Hope this helps!
Brandon~
- The topic ‘Unable to exclude page from navigation’ is closed to new replies.