HOW TO: 2014 theme – Remove Sidebar from Homepage or all pages [SOLUTION]
-
I searched around and found there was a lot of people with the same problem as me, which was how to remove the left-side black sidebar. There seemed to be a lot of confusion over how this was done and a lot of people gave really complicated solutions.
I am new to WordPress and by no means an expert but I resolved the issue under my own steam and found a fairly simple solution.
IMPORTANT! Both solutions lined out below require you to assign a page as your homepage in Settings->Reading->Front page displays, in the Admin area.
Remove Sidebar from Homepage only
I only wanted to remove it from the homepage so here is how I did that.- Assign the class ‘homepage’ to the homepage. In header.php replace line:
<div id="page" class="hfeed site">
with:
<div id="page" class="hfeed site<?php if(is_front_page()){ echo ' homepage'; } ?>">
This will then add another class to this line only for the homepage. - In page.php replace the line:
get_sidebar();
with:if(!is_front_page()){ get_sidebar(); }
This will then prevent the sidebar content being called on the homepage.
- Add the follow 2 styles to your style.css stylesheet:
.homepage:before { display: none; } .homepage .site-content { margin-left: 0px; }
These 2 styles will then only be assigned to the homepage. The first style removes the black background of the sidebar, whilst the second aligns the content to the left side remove the big margin.
Remove from ALL pages
I have not used this solution so cannot comment on its working but it should be fine.- In page.php replace the line:
get_sidebar();
with:if(!is_front_page()){ get_sidebar(); }
This will then prevent the sidebar content being called on the homepage.
- Add the follow 2 styles to your style.css stylesheet:
#page:before { display: none; } #page .site-content { margin-left: 0px; }
These 2 styles will then only be assigned to the homepage. The first style removes the black background of the sidebar, whilst the second aligns the content to the left side remove the big margin.
I hope these solutions work for people. If so please comment so others can also take advantage of this problem.
- Assign the class ‘homepage’ to the homepage. In header.php replace line:
-
just make sure to make these changes in a child theme of Twenty Fourteen;
Im trying to remove the side bar from my homepage only and I have a blank page created for my homepage in Settings->Reading->Front page displays & I understand step 2 & 3, but not sure about step 1. How do you assign the class homepage to the homepage? I’ve added the header.php to my child theme and looked through it for that code, but not seeing it… help? Thanks so much!
@roncarletonaudio – please start your own thread – this is not a good place to post new questions. If you are using twentyfourteen, post here:
https://wordpress.org/support/theme/twentyfourteen#postform
You can reference this thread if it’s relevant.
Is there a way to tag dunkleywayne since he was the one who posted the instructions?
@dunkleywayne :- Thank u very much..very useful post…solved the problem finally.
- The topic ‘HOW TO: 2014 theme – Remove Sidebar from Homepage or all pages [SOLUTION]’ is closed to new replies.