Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Hide the Sidebar on Your WordPress Home Page

Last updated on by
Follow WPBeginner on YouTube
How to Hide the Sidebar on Your WordPress Home Page

As you probably have noticed that most WordPress blogs have the same sidebar on all blog pages. While sidebar is important, sometimes it is not necessary for the homepage. In this article, we will share how you can hide the sidebar on your WordPress homepage.

One of the ways to do is by creating a completely new custom homepage for your WordPress blog, or you can simply make the change by using the code from this tutorial.

First open your index.php and locate the following code:

<?php get_sidebar(); ?>

Then Replace the code with:

<?php if (!is_front_page()) {
} ?>

And thats it. Now your Front Page will not have the sidebar.

Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »
  • Livi

    Visit number three to your site in the last 2 hours. HAD to subscribe. Worked perfectly.

  • Sandeep

    Wow that is just what I was looking for…

  • Zack

    After following your tutorial, the homepage sidebar gone, but the text of post are doesn’t fit to the page. why?

    • WPBeginner Support

      Some WordPress themes can have a <div> or other elements opening in homepage but closing in the sidebar template. Using this code in such a theme could break the layout. You can try to create a custom home page in WordPress.

  • Donna

    Not sure what I did wrong, but sidebar is still on the homepage

  • Ma Ke

    It doesn’t work in my blog. When I entered the index.php, site stats etc appeared. No codes. Any help?

  • Tomi

    Thank you very much!!!
    It worked perfect!!!!

  • Scott

    Thanks! Just what I was looking for, and worked as advertised.

  • Lucas Raby

    What if you want to hide it on the contact page rather than the homepage…? Thanks.

  • Milky Media

    Just wanted to add on this that I’ve been finding the ‘get_sidebar’ code in the footer.php.

    If you can’t find it in index.php, try there.

  • Junaid

    Nice and simple hack! Saved me some other theme modification that i feared would mess up things :)

  • Geekyard

    Great Hack buddy :) Works fine ;)

  • Dario Gutierrez

    Great tip dude! Thanks

  • joyoge bookmark

    thanks for the tip..

  • Alex Duvot

    thanks for the tip
    going to try this now

  • alaJoAnn

    Your instructions are a timely find. I just set up a static homepage and figured out how to remove the first code (and things looked right).

    Now I have pasted in the replacement code. I’m not a coder, but I bet doing that will avoid problems down the road.

    I shared this fix with my fellow PrimePress theme users at our support forum.

    • jmw456


      When I opened up my index.php file, the code didn’t actually have the bit you stated above. It only had the following text. Could you tell me which bit to replace here?