Have you ever created a page in WordPress and didn’t want it to show up in the sidebar menu with the title you saved it under? Well, a client recently wanted his home page titled “Welcome to Our Site” for when the visitor entered his domain, but wanted to show this page as his “Home” page in both the header and sidebar of his WordPress template.
After several failed attempts to search Google, and unanswered posts to queries in WordPress forums for a resolve for the sidebar, and I attempted to make the change myself. Voila… it worked!
Earlier on, I had discovered how to solve this issue with the header.php, but could NOT find help with changes needed in the sidebar. So, using what I was given to resolve renaming the page title for the header.php, which was as follows:
<li><a href=”<?php bloginfo(‘url’); ?>”>Home</a></li>
<?php wp_list_pages(‘sort_column=menu_order&depth=1&title_li=&exclude= 113′); ?>
Be sure YOU change the page numbers for exclude= 113′); ?> that YOU want excluded in YOUR WordPress template.
Here’s how you can discover the ID of your page. Sign in to your WordPress Admin panel and click on Pages. Locate the page you wish to hide in the navigation, and open in Edit mode… note what I have circled in red, in the screen print below. [click on image below to see a closer view. Use your browsers back button to return here.]
In this case, your number would be 145.
Anyway, after several attempts I decided to try using the following code:
<li><a href=”<?php bloginfo(‘url’); ?>”>Home</a></li>
<?php wp_list_pages(‘title_li=&depth=-1=&exclude= 13′); ?>
When I added this, the sidebar immediately gave 2 lists of pages to navigate… with “Welcome to Our Site” missing on the second, but “Home” appeared.
Then I located the following code in the sidebar.php:
<?php
foreach ($recentposts as $post) {
if ($post->post_title == ”)
$post->post_title = sprintf(__(‘Post #%s’), $post->ID);
echo “<li><a href=’”.get_permalink($post->ID).”‘>”;
the_title();
echo ‘</a></li>’;
}
?>
…and removed it all together. Voila! The sidebar appeared as my client wanted it to!
Finding help doing a Google search these days can be very frustrating, to say the least. However, knowing how frustrated I was in trying to get help with this…. I will post my resolve here, in hope that Google will offer it to you in YOUR next search for how to hide a page from sidebar navigation in WordPress.




howdy, I tried to contact you regarding this post but i cant seem to reach you. Please contact me me when get a moment. Thanks.
What is it you’d like to talk about? I’m right here!
Wow… saved by this. Thanks!
This worked wonders for me.. THANKS!
This worked PERFECTLY for me. THANKS!
Think I’d much sooner just use a plugin… but thanks for explaining this.
Pheeeew, thanks for this… my problem is now fixed.
Solution, time-saver, frustrated no more… thank YOU!!!!!!!!!!!!!!!!!!!!!!!!1
Randy sent me your post telling me it worked wonders for him. Did me too… thank YOU for this time-saving tip.
Wow… glad I’m not the only one having looked for this. Thanks!
Thank you for this!
What a great idea for tweaking my wordpress blog. THanks for this!
Whooo-hoooo… thanks for THIS!
Ta-dah! Worked wonders for me… thanks!
Thanks! Worked for me too.
Worked for me too… thanks!
Thanks for this!!!
Thanks for this!
Thanks!
Thanks for this!
Thank YOU for this!!!
Worked for me too… thanks!
Wow, what a time saver! Thanks for this!
Thanks for this!!!!!!!!!!!!!!
WoooHOOOOO… THANKS!