Quantcast
Channel: Crunchify
Viewing all articles
Browse latest Browse all 1037

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

$
0
0

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

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:

  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. Let’s get started:

Step-1

NOTE: Below steps applies to Genesis Framework. I’m using Eleven40 theme on Crunchify.

  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.

Have something to add to this article? Please chime in and join the conversation below.

The post How to Hide Sidebar only on Home, Archive page – Genesis WordPress Framework appeared first on Crunchify.
Author: App Shah

Viewing all articles
Browse latest Browse all 1037

Trending Articles