Hiding WordPress Pages

Ongoing WordPress Support

Do You Need Help With Your WordPress Site?

Click through to the next page and learn more about our ongoing WordPress care plans.

Date

How to hide pages from your main WordPress navigation section

I recently wrote a blog post on changing the order of your WordPress pages, as an extension to this post I thought I would write a little article on how to hide your blog pages if you don’t want them to appear on your main navigation bar.

Why Hide Pages

There is a good chance that you do not want to have every page you have created shown on your sites navigation section.  You may have private pages, that you only want to direct certain people to, or you may have so many pages that your navigation will overwhelm users.

Using the techniques below you can decide which pages your site visitors will see.

Examples of My Hidden Pages

I hide a number of pages on my Nav bar to keep my sites look and feel clean.  I do this because when people are visiting your site for the first time I think it can be overwhelming if there is too much information.  I also want to funnel people onto certain pages of my site so if I can keep their attention away from certain pages unless I want them to go there that is very useful.

I also have a number of hidden pages which run scripts for example I have conversion tracking pages for affiliate and payment processors.  I don’t want these to appear on the navigation bar.  I only want them to be used after a Paypal payment or to record an affiliate visit.

Here is one of my hidden pages

https://wpdude.com/welcome

I use this as my sneeze page from twitter or other social sites.

How To Hide Your Pages

There are two main ways to hide your pages, editing your theme, or using theme functionality or using a plugin.

Theme Specific

If your theme already has functionality to exclude pages just follow your theme instructions (mine does, so does Headway and Thesis) .  But if you are not lucky enough you may need to hack your theme code.

DISCLAIMER: I am not responsible for any crashed sites because you edited your code incorrectly.  If you don’t have the techie credentials don’t do this or get some WordPress help from  someone who does.  Please progress to the plugin section below if you are not a code monkey – thankyou and have a nice day

Inside of your theme files, most likely the header.php file there will be some code which lists your pages, it will probably look like this:

<ul>
  <?php wp_list_pages(); ?>
</ul>

To exclude a page, you need to add some parameters to the wp_list_pages function, and that is an exclude command with the post ID of the page to hide.  To find a page’s post ID, go to the  page editor and take notice of the URL in your browser bar.  Below is an example of my about page, as you can see my post ID is 2.

https://wpdude.com/wp-admin/page.php?action=edit&post=2

Now add this parametre to your wp_list_pages function as shown below:

  <?php wp_list_pages('exclude=1,2,3'); ?>

Where 1,2,3 are a comma delimited list of all the pages you want to hide.

Bonus Hide

If you take advantage of the parent/child page functionality of WordPress you can set your list page function to only show top level pages by adding the depth parameter.

 <?php wp_list_pages('exclude=1,2,3&depth=1'); ?>

Plugins

If coding your theme is a bit too much, don’t worry there is nearly always a plugin to solve every problem.  My favourite is the Exclude Pages plugin.  This adds a checkbox to the bottom of each page in the editor which allows you (as the name suggests) to exclude that page.  You can download it from the following link:

http://wordpress.org/extend/plugins/exclude-pages/

K.I.S.S (Keep It Simple Stupid)

Don’t bombard your blog readers with a huge number of pages that they may never need to see, keep your site design neat and tidy.  Less is always more in my book

3 thoughts on “Hiding WordPress Pages”

  1. Hello, Tnx for this Post, i am using Exclude Pages too, and it is really Easy.

    Do you know maybe a Plugin that will allow me to Hide MENU NAVIGATION from Some Page that i want?

    On some templates there is option in: PAGE ATTRIBUTES/TEMPLATE (i found option like: LANDING PAGE-NO MENU) on RESPONSIVE Theme.

    Like if i wont to make Thank You Page or something like that, and i dont want my menu navigation to Show on that Page, If you have maybe some solution for that, please inform me.

    Thanks in Advance and keep up the Great Work.

    1. I use the headway theme which has thsi functionality per page

      Or you could look at premise – getpremise.com which allows you to build landing pages without navigation

      or code up the header – this is pseudo code

      if (!is_page(name of page with no )){
      display menu
      }

Comments are closed.

Ongoing WordPress Support

Do You Need Help With Your WordPress Site?

Click through to the next page and learn more about our ongoing WordPress care plans.

More
articles