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
That’s the reason – it comes with so many hooks by itself in additional to WordPress hooks :).
While designing our another blog theme we had unique requirements:
- 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. Let’s get started:
Step-1
NOTE:
Below steps applies to Genesis Framework. I’m using Eleven40 theme on Crunchify.
- 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.
The post How to Hide Sidebar only on Home, Archive page – Genesis WordPress Framework appeared first on Crunchify.
Author: App Shah