How to Hide Sidebar only on Home, Archive page – Genesis WordPress Framework

Last updated
App Shah

Crunchify » WordPress Genesis Framework Tutorials » How to Hide Sidebar only on Home, Archive page – Genesis WordPress Framework

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.

Remove-Secondary-Sidebar-on-Home-and-Archive-Page-Crunchify

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

  1. Have two different sidebars only on Post and Page templates.
  2. Remove secondary sidebar on Home and Archive Page template.
  3. 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.

  1. Go to your site’s Admin console
  2. Click on Genesis
  3. Click on Theme Settings
Genesis-WordPress-Setting

Step-2

  1. Click on Default Layout section
  2. Click on sidebar-content-sidebar layout
Choose-Template-in-Crunchify-case-3-columns-with-2-sidebars

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.

Leave a Comment