How to Exclude Pages from the WordPress Navigation Bar

Excluded (by malias)

Have you ever wanted to create pages in WordPress but don’t want them listed in the header or footer navigation areas? You still want the pages to be accessible, perhaps listed in the sidebar, so you don’t want to make them private. You can do this by excluding pages and I’ll show you how to do it.

I have seven pages on this site but only 4, plus the home page, are listed in the header and footer. None of these pages have privacy settings. The remaining three are listed in my sidebar as links rather than in a list of pages. Do you know which ones they are? They are Bookmarks, Friendfeed Lifestream, and RSS Stream.

Pages are displayed with the following code, which is generally used in the header, footer, or sidebar.

<?php wp_list_pages();?>

This will list all of your pages until you add conditions in between ‘()’. You need to use the exclude condition and find out what number ID each page has. The exclude code looks like

<?php wp_list_pages('exclude=17,38' ); ?>
You can see that you have added 'exclude=17,38' to the original 
list pages code.

Of course, we need to locate the correct ID numbers for your pages.

Go to Manage > Pages and select the name of the page in which you would like to exclude. In the address bar of your web browser will be a URL that looks like the following.

The number at the end, 96, is the ID number for the page and is the number you will use in the exclude code. You can do this for each page that you want to exclude as long as you put a comma between the page numbers in the code.

Are there other tweaks that you would like to add to your list of pages? Ask me about them in the comments and I will answer your questions. Or if your comment really inspires me I will write an entire article about it :-)

photo credit: malias

It's Time!

Start your development project now!

Contact Me! >>


Keep Reading:
How to Add the Post Thumbnail Feature to your WordPress Installation
How to Include a Post on a WordPress Static Front Page with the Thesis Theme
Add WordPress Documentation for Your Clients with the WP Help Plugin
Closing WordPress Comments on Posts Over 100 Days Old


  1. Kim Woodbridge says

    @Mark – Thanks! I’m glad that you found the article useful.

    @Vered – If you follow the instructions in the article, you can exclude the legal page from your sidebar. In the Manage > Pages there is a section called Permalink right below the title. This is the link that you would use in the footer. You could edit the footer page in the theme editor and add a legal link maybe where you have the WordPress and theme information.

    If you want to discuss further, send me an email. kwbridge at

    Feel free to email me anytime, Vered.

  2. Kim Woodbridge says


    I know that I’m a backup nag but make sure you make a copy of the templates before you make any changes. I’ve learned that the hard way – repeatedly – lol. :-)

  3. says

    Thank you for this information. It’s the best description of this that I’ve found. (And I’ve really been looking.)

    All I have to do now is to find the right place for the code in my theme.


  4. Kim Woodbridge says

    Hi Lynn,

    Thanks for stopping by and commenting. I’m so glad that you found this helpful. Many articles on these topics make it overally complicated so one of my goals is to write the tip in regular language.

  5. says

    Hi Kim,

    Right now I’m trying to incorporate the exclude code with this:

    I thought of just including a separate set of quotation marks with your exclude code in them, but that gave me parsing errors. A separate set of brackets with the quotation marks with the exclude code gave me another error. Any suggestions?


  6. says

    Okay, I’ve included the exclude code within the one set of quotation marks, and there it excludes everything except for the about page, even if I use the ID for the one page I want to exclude. I subscribed to your RSS feed by the way :) Thanks again for posting this – it has given me a direction.


    Ben McFarlane’s last blog post – Make Your Mixes Wider than Ever

  7. Kim Woodbridge says

    Hi Ben,

    Thanks for visiting, commenting and subscribing :-)

    I’m sorry that you are having trouble with the exclude code – it’s usually one tiny little thing that keeps these things from working,

    It does have to be in single quotes and each page you want excluded needs to have the page ID number with a comma between.

    If you want post the code here and I will take a look at it. Leave off the beginning and ending bracket and question mark or it won’t display properly in the comment. Or feel free to email it to me at kim.woodbridge at gmail . com

  8. Kim Woodbridge says

    Awesome! I’m so glad you got it to work!

    And the design of your site is great. Is it a custom theme or a modified one? It looks like it might be based off of Revolution …?

    Please keep visiting :-)

  9. Jon says

    Hi Kim, this tip works great for me except that I already have a condition in that particular php operation:

    I don’t know anything about php so I don’t know how to also call the ‘exclude’ condition. Various ways of combining both conditions in the same operation resulted in syntax errors. What’s the correct way of including both the title and exclude conditions?


  10. Jon says

    Whoops, I tried to post my existing code but I guess it wouldn’t let me. Here it is with some extra spaces:

  11. Jon says

    …arghh, no dice again. I guess I can’t post anything that looks like code. Anyway it’s this:

    less-than symbol ?php wp_list_pages(‘title_li=’); ?greater-than symbol

  12. Kim Woodbridge says


    Sorry about the code problem. I will be sure to add instructions to this section. I have the following

    < ?php wp_list_pages('depth=1&sort_column=menu_order&exclude=7,114&title_li=' . ('') . '' ); ?>

    I don’t totally understand the title_li part at the end but I do know that it works.

  13. Kim Woodbridge says

    @Nick – Strange – I wonder how your pages are being displayed. I’m glad you found a solution to do the job for you.

  14. Ajax says

    Hey Kim, i have a little problem with my code, and you seem to be the perfect person to help me.
    My code is displayed like this :

    And I want to exclude the page 22. Where should I try to put the exclude code, because everything seems to be wrong.

    Thanks a lot and thank you for this tip.

  15. Kim Woodbridge says

    Hi Ajax,

    I sent you an email because the code didn’t show up in the comment. I hope that helped. (I really need to provide instructions for the comments).

  16. says

    Hi Kim,

    THanks for these great tips! I did add your code, as I too was in need of having pages not connected to the menu bar, but I found an interesting by-product – my sub- pages are no longer showing as a pull down off the menu (prior to making the code change, when I selected my “services” menu item, a drop down list showed up of all the sub-pages – but no longer).




    Rodney´s last blog post – Innovation

  17. says

    @Rodney – Thank you for visiting and commenting.

    Do you use a script to make the dropdowns work? So far, all I can come up with is that there is a conflict between the script and the code.

  18. says

    my navigation php looks like this:

    get_results(‘select ID, post_title from ‘. $wpdb->posts .’ where post_status = “publish” and post_type = “page” order by ID’);

    return $these_pages;

    function list_all_pages(){

    $all_pages = get_the_pa_ges ();
    foreach ($all_pages as $thats_all){
    $the_page_id = $thats_all->ID;

    if (is_page($the_page_id)) {
    $addclass = ‘ class=”current_page”‘;
    } else {
    $addclass = ”;
    $output .= ‘ID).'” title=”‘.$thats_all->post_title.'”>’.$thats_all->post_title.’‘;

    return $output;


    if (is_home()) {
    $addclass = ‘ class=”current_page”‘;
    } else {
    $addclass = ”;
    echo “Home“;
    echo list_all_pages();?>

    where i should add the exclude pages….i am not expert with php :P


  19. says

    Hi Eve,

    Your pages are being listed using a function rather than the standard
    code. Are you using a premium theme? If so, does it have an options are
    to set the pages? I don’t actually know how to exclude pages from that

  20. says

    yes, i already ask them, they do not reply yet :)
    I must choose different theme, the problem is i am not a pro with modifying css, so i don;t know how to add banner place at the top of my blog and also the sidebar. (this is the very reason i choose this theme although their coding is very weird :P).
    You have tutorial for that?

    thanks for your kind care and reply, i am your fans now LOL

  21. says

    Hi Kim,

    excuse my very silly question, but php code is a bit new to me.

    what file am I adding the above exception code too:

    I have looked through header.php, themes.php, and others and can not see what you are referring too.

    Thanks for your help :)

    • says

      Hi Tammy,

      The code should be in header.php I have found, however, that some themes call a function in the header and that the code is located in the functions.php file instead.

      • says

        Hi Kim,

        Sorry for the delay. I finally found the code you mentioned in the header.php file – Thanks

        However I get errors when I add the exclude code

        1. when I add it like this
        I get this error: Parse error: syntax error, unexpected ‘(‘ in /home3/normquan/public_html/wp-content/themes/1729/CB-Outdoors/header.php on line 33

        2. when I add it like this
        I get this error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home3/normquan/public_html/wp-content/themes/1729/CB-Outdoors/header.php on line 33

        Thanks for your help.


        Tammy´s last blog post – An Illustration of Power Differential between Men and Women

  22. Marion says

    Do you know of an easier way than include and exclude to create separate nav bars? I have a client’s site I’m working on with 4 main navigation buttons which are hard coded because they won’t change…and another nav area with global links to About, Contact, Employment, etc…If i use the include or exclude tags in the Global Links, then the client will have to open the header.php file if he adds pages himself, which I’m sure he will. Is there any way to use fields within the CMS to “assign” a page to a nav area? For instance, I’ve used a custom CMs where you could choose whether a page was a MAIN button or a UTILITY button…can WP be tweaked somehow to do the same thing in a way the client does NOT have to open PHP files? Thanks for any advise!

  23. says

    Hi Kim,

    So I’m working on my new project, and search for “wordpress exclude pages from navbar” and who holds the first position for that search string? You. How exciting.

    Anyway, what you shared with Jon was just what I needed. At first I messed up and didn’t move the single quotation mark to the end and got a parsing error, but when I corrected my mistake, it worked perfectly.

    You’re awesome Kim.

    Thank you!
    .-= Barbara Swafford´s last blog ..Caution – Read At Your Own Risk =-.

    • says

      Hi Barbara – I’m so excited my site actually came up first in a search result. And I’m so glad the article helped you out. Single and double quotes tend to be the bane of my existence ;-)

    • says

      Hi – Yes, a lot of people use the plugin instead. Last night I made a number of pages that I didn’t want in my navigation bar and was almost wishing I used the plugin because I had to add so many pages to the exclude.

  24. says

    Thanks for the post Kim
    Spent a good hour pulling my hair out though trying to find that code in the theme editor. It is not there anywhere. Same problem as Nick on Oct 19. His link to the plugin “exclude pages” however fixed the problem, worked a treat and I stilll have a few hairs left:)).
    The theme I am using is called ZenHealth if you wanted to look into it more.
    Thanks. Take Care.
    .-= Chava Vital Chocolate´s last blog ..Waiora Agarigold – Agarigold H1X1 =-.

  25. says

    In my blog,i have to add a code to the page.php (a must for me)

    I added the code and works fine in a specific page which i created but the problem is that,when i added the code all the other pages like contact,privacy policy shows it.I just want to show it in that specific page i created

    An example:I created a page let’s say X.I added this code. to page.php
    Normally all the pages(contact,privacy policy) shows it.I don’t want this code to be shown in those pages but only in X page

    Is there a way to exclude that code from other pages not to show it?
    .-= Cini´s last blog ..70 Attractive Examples Of Big Typography In Web Design =-.

  26. says

    I found this post while looking for a way to make pages completely invisible, like a thank you page for an autoresponder — and there’s the post above! Turned out this helps with another problem I’ve been meaning to deal with.

    My page has a little more code on that line, so I’ll have to figure it out. Shouldn’t be hard, and I’ll do it on a test site first. Thanks for showing the way!


  27. Adil says

    Thanks for the info,
    How to exclude the pages from header if the given code is not like and we have a code in function.php like this. Thanks

    function art_get_page_title() {
    $name = get_bloginfo(‘name’);
    $cat = single_cat_title( ” , false);
    $post = single_post_title(”, false);
    $result = “”;
    if (is_home () ) {
    $result .= $name;
    } elseif ( is_category() ) {
    $result .= $cat;
    if($name != “”) $result .=’ – ‘ ;
    $result .= $name;
    } elseif (is_single() ) {
    $result .= $post;
    } elseif (is_page() ) {
    $result .= $name;
    if($name != “”) $result .= ‘: ‘;
    $result .= $post;
    } else {
    $result .= wp_title(”,false);

  28. says

    When you go to print preview on your page or on my website, at the top of any/all of the pages it prints out the complete list (out-line) of all pages above the stuff you really want. Most website pages don’t do this. Seems to be a WordPress anomaly. The person who helped me set up my pages couldn’t solve my problem. I was wondering if you could. Thank you

    • says

      Hi Kathy – I’m not sure why that isn’t showing up. When I do a print preview of my page the list of pages is at the top. Sound more like a browser issue than a WordPress one.

  29. says

    Doing this (exclude) will not unpublish any pages? but it only remove from navigation, right ?

    I must stumble your page because it helped me completing one of my gig at fiverr

  30. daniel says

    Hi Kim,
    Thanks so much for posting this.

    I’m trying to get my pages not to appear anywhere, but only be accessible through a link (from an image).
    Is this possible?

    Also, is there anyway to exclude the Main blog title from the top of each page???

    Thanks so much,

    • says

      Hi Daniel – Yes, if you don’t have a navigation menu or list of pages you can hide all the pages. I’m not sure how you want the images to work but you could set them up and have them link to the specific pages.

      You can exclude the title – how this is done will depend on the theme that you are using. It is usually done by removing the code that displays it from the theme’s template files.

  31. Bruce says

    Hi Kim,
    I’m unable to find the location in the standard WordPress Twenty Ten 1.2 theme where to make these edits. Can you advise which file needs to be edited and where in the file?

    Thanks very much for the fine info you convey so well!

      • Bruce says

        Hi Kim,
        The link has ALREADY been deleted in the built in menuing system, and the change saved, yet it STILL appears on all of the site pages!! That’s the reason I am looking for a place to make a manual adjustment as the change is not taking place in the menu system as it should. Very perplexing!! Thanks for any help you may be able to provide.

        • says

          Are you using a caching plugin that might keep you from seeing the change? Or have you tried looking at it in a different browser? As long as the menu being used is the primary one the changes should appear without any additional tweaks.

    • says

      Hi Sal – This article is old and menus can be managed via Appearance > Menus if your theme and WordPress version supports it. Typically, this code, however, is found under Appearance > Editor > header.php

  32. Rohit says

    Nice tip but isn’t there any function in admin panels from there we can hide the page because i my website have many pages it will be difficult.Pls suggest me with any plugin or any other methods to do

  33. says

    Hello admin. I can’t exclude page if the code look like this

    'primary', 'fallback_cb' => 'zbench_wp_list_pages', 'container' => 'false', 'items_wrap' => '%3$s' ) ); ?>

    Anyone can help me please?! :)

  34. Christian says

    My users create pages , so how about if alot of pages are being created at once ? I cant manually be putting them inside the code. It will take forever ! Isnt there another way to have the pages listed in the sidebar and not displayed on the menu?

  35. says

    Go to edit page, on the right hand side, under Publish, there is a box that say’s Visbility:public click edit, and make the page private, its as easy as that.
    Hope this help’s anyone.


Comments are closed. Please contact me for specific questions or subscribe to my newsletter.