Excluding Pages from List in WordPress

Posted by beThinker | Posted in WordPress | Posted on 05-06-2009

WordPressIn this tutorial will show you how to hide a page or post in a simple way without using plugins and I’m sure that there are lots of plugins out there that exists.

There may be a time when you are adding pages or post to your blog that you don’t what that page or post to show up in main navigation or in a list of post. I have a thank you page and I only want to show it up after the user click the submit button in my register page. So lets get started.

Make sure you have FTP access to your site then find your blog’s current theme directory (domain/wp-content/themes/nameOfTheme). Look for the header.php open this file in your favorite text editor.

For pages try to look find this code:

1
2
3
<ul>
   <?php wp_list_pages('title_li='); ?>
</ul>


Now will use the exclude parameter to hide certain Pages from the list to be generated by wp_list_pages.

First thing we should know the ID number for a certain page. And how we should know this, go into your WordPress Administrator panel, click Pages, then drag the mouse over to the page that you want to hide and see on the status bar the ID number for that page. For example the Thank you page and I have an id=20. So the code should look like this now:

1
2
3
<ul>
<?php wp_list_pages('title_li=&exclude=120'); ?>
</ul>


Notice we have extra code which is tittle_li and exclude. Now tittle_li is the list of pages and the exclude is the one who hide a certain page/s. Even though the page is hidden you can still access it using the page link. For multiple pages to be excluded just used comma to separate each ID numbers. Don’t for get the & sign to separate the tittle_li and exclude.

If you still don’t get it please don’t hesitate to leave a comment or send me an email and I’ll do what I can to get things working.

Sponsored Links

Write a Comment