When we list the pages in the WordPress to show the navigation to the pages we have on our blog/site by using this code:
<?php wp_list_pages(); ?>
It displays the list of the pages we have in our WordPress blog installation in a navigation form, showing links to all the pages.
Now some times we want to remove some of the links / pages from being listed in the navigation of WordPress pages. Here is how to exclude those unnecessary links from being displayed in the wordpress navigation for pages.
You need to add some in the list pages code for wordpress pages navigation, and also tell it the id of the page that you want to be excluded/removed. To get the number/id of the page that you want to remove, simply goto wordpress admin, and goto pages(edit pages) and there click on the page you want to be removed/excluded from the wordpress navigation for pages. On next edit page, note the url(address) of the page that you are on, and not down the last post number in it. It should be like this:
So in this case, the page number was 92. Now simply change your navigation code for wordpress pages to this one including the variable exclude to remove the specified page from the wordpress pages navigation:
<?php wp_list_pages(exclude=92); ?>
If you want to exclude more than one pages in the wordpress navigation, simply add them there seperated by comma (,) like this:
<?php wp_list_pages(exclude=92,93,94); ?>
Hope it solves the problem. Lemme know if you are in some other situation and want it to be fixed.
16 comments on “How to remove specific page(s) link from the WordPress Navigation”
you are welcome sir! :)
very handy one
thnx for sharing
I really like the widget and have recently installed it however I am unable to modify any of the attributes of the widget. I am not sure if I can or not. The options interface seems to be ineffective. I am currently using WordPress 2.3
Yeaar, super plugin! Thanks a LOT!
thx for this plugin
@wholesale. . . which plugin are you talking about sir?
I have the following code Using Iphone template:
<a href="”> <img src="/images/home-icon.png” />
Cant seem to get rid of page 23 from menu and tried different variations of the code. Can any one help
@Gary, please explain your situation a bit more, also show me the link to your site.
Assalamu Alaikkum Nabeel
Great Post One more thing is if you are using certain themes like studiopress,pyrmont etc you have to add “If ($the_page_id!=3 && $the_page_id!=2) before if (is_page($the_page_id)) ” ie the pages you are excluding are 3 and 2 so that it works great Happy Eid ul-Alha Friend
Eid Mubarak to you too!
I am the first time on this site and am really enthusiastic about and so many good articles. I think it’s just very good.
thanks for appreciating
Hey i am having one problem in my navigation bar the problem is all my categories are displaying in the navigation bar so i want to fix this problem so plz have a look on the site and plz suggest me step by step to fix this problem. http://www.salmankhanzone.com/
i saw it earlier (you removed categories now maybe) however you need to add filter to the categories list to hide some of them
let me know if you want me to do this for you.
Thank You so much for your reply Nabeel yes i have added filter to the categories list now.
one more thing, install: firebug and page speed plugin by google and then optimize / replace your theme to make it light weight + bug free. Try keeping your page below 100kb (or 200kb atleast)
I really appreciate for your support, thanks man yes i am already using firebug and page speed plugin my site is still under construction so working on that.
Thanks man for your support again :)
btw, use w3 total cache on your blog too, it’s really a wonderful plugin (when configured properly) I might be making a post on it’s use and configuration too