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
Special WordPress Hosting offer for WPBeginner Readers
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 experts 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 »


  1. Darryl Gebien says:

    Confused re: “First open your index.php and locate the following code:”…which “index.php” file? There’s several in my directories in File Manager.

    Hierarchy is:

    Root > Public_html > thebalconycleaners > then which subfolder? (wp-admin vs wp-content vs. wp-includes). My guess is wp-content > themes > twenty sixteen > index.php file, however the code changes didn’t work.

    Which is the correct one to change please?

    Thanks for any help!

    • WPBeginner Support says:

      This tutorial is talking about a index.php file in your WordPress theme. You can find your WordPress theme files by connecting to a FTP client and locating /wp-content/themes folder. Inside the themes folder you will find a folder with your current active theme’s name. Open this folder and you should be able to find a index.php file among many others.

      You can also see this file by visiting Appearance » Editor. Look at the list of files on your right and you will see index.php among other files. However, be very careful editing file from WordPress admin area. A tiny little mistake can lock you out of WordPress admin area.

      • Darryl Gebien says:

        Thank you for your reply but I double checked using FTP and the Editor you mentioned and confirm the changes are there, but it’s still not working on my homepage.

        Please advise. Ty!


        • Darryl Gebien says:

          I finally did it by removing all widgets from the sidebar using the Customizer. Is this how you recommend?

  2. Mandy says:

    Hi, thank you so so so much! I’ve been trying all sorts of codes/css modification for days, and finally came across your page and it works! I have finally removed the sidebar on home page, with other pages unaffected, like I intend them to.

    I do wish the front page content can be expanded to fill out the removed sidebar. Do you have a code that helps?


    • Abbas says:

      For solving that problem and fill out the removed sidebar, I added this code in “index.php” for changing “width” of the primary content in homepage:

      <div id="primary" class="content-area" >

      In the case of different themes, this style may be different.

      • Chay says:

        Hi Abbas,

        Where do you add the ?

        I put these code in my page.php, instead of index.php as they are not working on index.php

  3. Livi says:

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

  4. Sandeep says:

    Wow that is just what I was looking for…

  5. Zack says:

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

  6. Donna says:

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

  7. Ma Ke says:

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

  8. Tomi says:

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

  9. Scott says:

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

  10. Lucas Raby says:

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

  11. Milky Media says:

    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.

  12. Junaid says:

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

  13. Geekyard says:

    Great Hack buddy :) Works fine ;)

  14. Dario Gutierrez says:

    Great tip dude! Thanks

  15. joyoge bookmark says:

    thanks for the tip..

  16. Alex Duvot says:

    thanks for the tip
    going to try this now

  17. alaJoAnn says:

    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 says:


      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?

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.