Remove a page link from the top menu navigation in WordPress

by mitz on May 22, 2010

If you are into WordPress websites you will most likely come across the problem of a page that you do not want showing appearing in the top navigation menu. Sometimes you can install a plugin to help customize the top navigation menu, however these plugins react differently for each WordPress theme. This is why I like to remove or exclude the pages I do not want in the top navigation menu manually. I do this by editing the php code in the header.php.

How to remove or exclude a page from the navigation menu in WordPress?

1.  Sign in to your WordPress dashboard
2. Click on the appearance link in the side menu
3. Then choose editor
4. Some themes are different, however in this case I want to edit the header.php file
5. Click on header.php to edit
6. Find <?php wp_list_pages(‘title_li=’); ?> or something similar
7. Paste the new code in: <?php wp_list_pages(‘exclude=32&title_li=’); ?>
8. If you have menus with submenus than use this code: <?php wp_list_pages(‘depth=2,3,5&exclude= 2&title_li=’); ?>

Watch this video tutorial showing you how to add the code into the header.php file.

Here is another example of how I had to customize this code to get it to work.

$string = wp_list_pages(‘title_li=&echo=0&depth=1&exclude=3962,4779′);

As you can see it is very similar to the previous examples.

Related posts:

Related Posts

This post was written by...

– who has written 187 posts on Wordpress Website builder.

I am addicted to internet marketing and making money online. Who wouldn't want to live that life? I started out with one website as a hobby and now have over 20. Come and join in the fun and share your knowledge about building Wordpress Websites. If you are interested in guest posting for this website click here to see more details.

Submit your own guest post now!

{ 12 comments… read them below or add one }

Brenda Macalino January 30, 2012 at 10:03 pm

For me the new version is nice than to the old wordpress.. because there something with this new version..
Brenda Macalino recently posted..singapore home loans

Reply

dezza July 12, 2011 at 11:25 pm

hi
I am using the easel theme which does not have the code in the header.php that you refer to – any suggestions where else it could be.
I wish developers would not include page titles at the top as it looks cumbersome when you have many pages.

Reply

Salmonido August 9, 2011 at 3:02 pm

Hi

I’m having the same problem. I’ running my WP with Easel theme and I cannot hide pages from menu. header.php doesn’t have wp_list_page instead of that, there’s a menubar.php wich doesn’t include this code. HELP!

Reply

David June 16, 2011 at 2:07 am

Thanks for this help. I’ve started using 8Bit’s “Standard Theme” recently and they seem to be processing the Top Menu differently. The work around I discovered was to simply make certain the “offending” page had a parent in the Page Attributes. Hope this helps.

Reply

Gavin February 22, 2011 at 2:55 pm

Thanks dude! That worked perfectly for me.

Reply

Jenny November 29, 2010 at 6:45 am

I tried this and it didn’t work and then I went back to the way it was like you said and I got this error message

Parse error: syntax error, unexpected ‘=’ in D:\Hosting\2756737\html\wp-content\themes\snapshot\header.php on line 67

What i am trying to do is remove the existing home page to make my second page the home page and I can’t seem to get that to work. Any suggestions?

Reply

nero June 5, 2011 at 11:30 pm

@Jenny

I just came across this post and ended up with exactly same error.

After dropping it into my text editor, rather than making the edits in the WP Admin, I noticed that if you cut and paste from this page that the apostrophes are actually smart apostrophes.

Just swap them out and it works like a charm.

Reply

henry515 October 8, 2010 at 5:13 am

Hey it’s not working please can you help me i cant find the Editor link at the Appearance bar… I have the Digg Colummn theme and i really need to remove the pages im stuck :(

Reply

mitz October 8, 2010 at 7:54 am

Hi there
I am not sure if you have an editors link in the free hosted Wordpress. If it is not there then it means you cannot do this.. I had a free hosted Wordpress website years ago and found that it had many things I couldn’t do so I bought my own web hosting space.

Reply

Casey July 12, 2010 at 5:11 pm

Awesome. Just pasted the code into my header, on Wordpress 3. Omitted the page.

THANK YOU for the tip. Really saved me here.
Casey recently posted..youtube

Reply

mitz July 13, 2010 at 7:05 am

Glad to help…It’s great to find the answer to a problem quickly without having to waste too much time.

Reply

Acer June 24, 2010 at 4:19 pm

What about the same in the latest Wordpress 3.0 ?
Acer recently posted..Acer Aspire 4736Z Laptop – Windows 7

Reply

Leave a Comment

Please use your REAL NAME@KEYWORDS or just your REAL NAME to get approved. Worthless generic comments will be deleted. Please see these tips on how to get approved.

Previous post:

Next post: