Do you have requirement to remove Sidebar On Genesiswp Home, Page or Posts? Do you want to disable your WordPress sidebar on any page or post? Well – you are at right place.
We are using WordPress Genesis Framework on all of our sites. At present moment it’s very popular WordPress theme framework because of below default features:
- Responsive HTML5 Designs
- SEO ready themes – But I don’t use this feature. I use
Yoast SEO
plugin instead. - Customizable and Fast
- Widgets & Layout Options
- Integration with WordPress Customizer
- Lots of API integration
- Extensive WordPress community support
In addition to above the reasons – it also comes with so many hooks by itself in additional to WordPress hooks :).
Sometimes while designing our clients site/blog theme, we come across so many unique requirements:
Let’s go over this scenario
- Have two different sidebars only on
Post
andPage
templates. - Remove secondary sidebar on
Home
andArchive
Page template. - Change CSS on Home/Archive page in case of only 1 Primary sidebar. For this point take a look at tutorial on How to apply CSS on only on Home/Archive/Page template.
In this tutorial we will go over point 1 and 2 from above scenario.
Let’s get started:
Step-1
NOTE:
Below steps applies to Genesis Framework. I’m using Eleven40 theme on Crunchify.
This tip works with all other Genesis themes too.
- Go to your site’s Admin console
- Click on
Genesis
- Click on
Theme Settings
Step-2
- Click on Default Layout section
- Click on
sidebar-content-sidebar
layout
Step-3
Let’s first understand. Genesis enabled two sidebars with name genesis_sidebar
(Primary) and genesis_sidebar_alt
(Secondary).
Now our task is to remove secondary sidebar
on Home/Archive
pages. Below hook will do exactly the same. Put code into your child theme’s functions.php
file.
add_action( 'genesis_before_loop', 'crunchify_remove_sidebar_hook' ); function crunchify_remove_sidebar_hook() { if ( is_home() || is_archive()) { // add is_search() to disable sidebar on search page remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' ); // this removes secondary sidebar // remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); // this removes primary sidebar // uncomment above line to disable primary sidebar } }
Hope this helps.
If you are using Genesis Simple Sidebars
plugin then it’s better to uninstall and remove before applying above changes.
Don’t forgot to change your CSS
which we describe in other post.