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()) {
get_sidebar();
} ?>
And thats it. Now your Front Page will not have the sidebar.
I tried it but it not work with twenty sixteen theme
How can we remove the sidebar from a genesis homepage (blog page), using a genesis child theme?
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!
Darryl
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.
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!
DG
I finally did it by removing all widgets from the sidebar using the Customizer. Is this how you recommend?
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?
Thanks!
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.
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
Hey, what exactly did you change in the index.php to fill the removed sidebar with content? I tried to interpret what you were saying here but i can’t seem to get it, because this: “” is already a part of the index file..
Help would be much appreciated.
Visit number three to your site in the last 2 hours. HAD to subscribe. Worked perfectly.
Wow that is just what I was looking for…
After following your tutorial, the homepage sidebar gone, but the text of post are doesn’t fit to the page. why?
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.
Not sure what I did wrong, but sidebar is still on the homepage
It doesn’t work in my blog. When I entered the index.php, site stats etc appeared. No codes. Any help?
Thank you very much!!!
It worked perfect!!!!
Thanks! Just what I was looking for, and worked as advertised.
What if you want to hide it on the contact page rather than the homepage…? Thanks.
Then you use one of the available WordPress conditional tags to do so.
http://codex.wordpress.org/Conditional_Tags
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.
Nice and simple hack! Saved me some other theme modification that i feared would mess up things
Great Hack buddy
Works fine 
Great tip dude! Thanks
thanks for the tip..
thanks for the tip
going to try this now
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.
Hi
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?