Joshua David Nelson

Bullshit Free WordPress Development

  • Services
  • Code
  • About
  • Contact

An Alternative Sidebar Page Template in Genesis

November 18, 2013 by Joshua Nelson

There are plenty of methods to achieving different sidebars on specific pages, even switching sidebars in Genesis. One I like for simplicity uses the Secondary Sidebar in Genesis as the alternate sidebar – rolled into a page template.

The default description for the built-in secondary sidebar doesn’t really apply, so first we’ll unregister that sidebar and re-register it with our preferred description. Place this in your child theme’s function.php file:

<?php
/**
* Place this into your functions file
*
*/
unregister_sidebar( 'sidebar-alt' );
genesis_register_sidebar(
array(
'id' => 'sidebar-alt',
'name' => 'Alternate Sidebar',
'description' => 'This sidebar will appear instead of the primary sidebar, when the alternate sidebar page template is used.',
)
);
view raw functions.php hosted with ❤ by GitHub

Then create a new page template, called something like template-alt-sidebar.php for instance, with the following code:

<?php
/*
Template Name: Alt Sidebar Page
*/
add_action( 'genesis_sidebar', 'genesis_do_sidebar_alt' );
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
genesis();
view raw template-alt-sidebar.php hosted with ❤ by GitHub

Now you’ll see the secondary sidebar in your widget area with a proper description and have a page template for the pages you want that sidebar to appear on. Plus, it uses the built-in Genesis sidebar name and hooks for ease and compatibility.

Obviously this template only works with single sidebar layouts. It will still allow you to use double sidebar layouts on other pages, though. If you are looking to make your sidebars and widgets more page-specifics, consider using the Display Widgets plugin, which allows you to choose where each widget in the sidebar is displayed.

Filed Under: Genesis, Intermediate, WordPress Tutorials Tagged With: Genesis, Genesis Tutorial

  • Twitter
  • RSS Feed URL

About Me

I'm a WordPress Engineer. I build sleek, custom websites with WordPress and Genesis.

See my services and my recent work.

Contact me to get your project started.

Gravity Forms Plugin for WordPress Fastest WordPress Hosting

Recent Posts

  • Using Font Awesome Icons for WooCommerce Grid / List Toggle
  • Disable Blog: WordPress Gone Blog-less
  • Category (Taxonomy) Dropdown Filtered By Post Type
  • Weather in WordPress with Dark Sky
  • Fixing Your Deprecated Widget Constructors in WordPress 4.3
  • Twitter
  • RSS Feed URL
  • Code Snippets
  • My Plugins
  • Make a Payment

© Joshua David Nelson | Hand-Forged | WordPress + Genesis | Terms of Service | Legal | Contact