Phone: (+44) 7801-560132

Blog

Hiding Pages in WordPress

[LikeMe id=1]

Have you ever wondered if it would be possible to hide a particular page name from the navigation bar at the top of your blog?

You could make it “Private” – but then no-one else but logged in members would be able to access it.

Mmmm…….

Creating a hidden page in WordPress

Sometimes it is handy to be able to “hide” a WordPress page from the public as opposed to making that page “Private”. What’s the matter with private pages I hear you ask?? Well nothing – if you don’t want anyone except those who are logged into your blog, to access that page. The problem with “Private” pages is that they are very good at what they were designed for!! – Being Private and un-available most times!!

Consider a Thank-You page for a moment – if you want a Thank-You page to look like your present wordpress theme it is very easy to create a new page and there you have it! However – what happens when your theme automatically creates a menu somewhere or other with a list of Pages?? Depending on your theme, there is probably a list of all your static pages (by default) somewhere on your website (navigation bar, sidebar, widget, sitemap or whatever). What happens if you don’t want that particular page to appear – yet you still need it to be available to your visitors in certain circumstances??

Read on . . . .

You create a static page and call it whatever you want. You note the page ID number for this page and locate the PHP template in your theme that calls the list of pages. It will probably be named sidebar.php or sitemap.php

You are looking for a line like this: < ?php wp_list_pages('title_li=' ); ?>

Note: It’s a good idea to save a copy of this file before you alter it and rename it something like file_nameORIG.php, in case you ever need to restore the default and forget what you’ve altered.

Now, add ‘exclude=page_ID&’ to the line (substituting your actual page ID).

If your page ID is 22, it would look like this: < ?php wp_list_pages(‘exclude=22&title_li=’ ); ?>

You can add more pages separated by commas but read on before you do so because you may not need to, even if you think you do. OK, save, to upload your file to replace the one on your server. That’s basically it. Now, whenever you want to add a static page that should not appear on your master list, just make it a child of this excluded page. You can make any of the children of this parent page visible again by simply making them parent pages, or by making them children of a parent that is visible. Simple and elegant!

But, you ask, what use is this? Well, for one, you can store drafts of pages or make pages private. They are not true drafts or private pages because if someone knows the page ID, they can access the page, but it works in a manner of speaking and I find it useful to have that option. Where I found it most useful however, like I stated above, was in creating a thank-you page. I prefer this method because it serves double-duty and does not require a plugin. I just created a thank-you page so that, for example, you can direct your new subscribers to that page – rather than the default autoresponder one. It obviously then keeps your “theme” without going “outside” the blog structure.

Hope you found that useful.

This Post Has 1 Comment

Leave A Reply

You must be logged in to post a comment.