Site icon Nabtron

How to remove specific page(s) link from the WordPress Navigation

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:

http://www.domain.com/wp-admin/page.php?action=edit&post=92

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.

Exit mobile version