Genesis Theme Tutorial: Invisible Primary Sidebar

Genesis Theme Tutorial: Get Rid of the Primary Sidebar (but Keep the Secondary!)

I’m working on a project using the most excellent Education Theme from StudioPress. I love the double sidebar (content/sidebar/sidebar) layout on this theme, but found myself needing to get rid of the primary sidebar and go full-width on a couple of pages. The catch? I wanted full-width in the main area, while keeping that secondary sidebar hanging off the edge (essentially a content/content/sidebar layout).

The Genesis Framework makes it easy enough to change the layout on a page by page basis, or even remove the primary or secondary nav via filter hooks. But how can I ditch the primary sidebar while keeping the secondary?

I found a CSS solution that did the trick. Ready? Here goes!

Setting the Stage – Remove the Primary Sidebar from a Single Page

Remember, I actually want my primary sidebar on the rest of the site. But for THIS page, I want the primary sidebar to go away completely so that I can use that space for my main content.

Genesis Primary Sidebar ExampleGenesis Primary Sidebar Example

I could use an action hook like this…

if ( is_page('special-page') ) {
     /** Remove default sidebar */
     remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );

…but that only makes the sidebar disappear and leaves a gaping hole in the layout.

Genesis Primary Sidebar Gone

So that’s not the solution.

The Fix

Step 1: Use Body Classes to target your page via CSS

We’re going to go with a CSS-only solution. I want to be able to target my special page via CSS, so I’m going to use a Body Class. First, I’ll tell you how to add a body class to your own special page, then I’ll tell you what it does.

Scroll down to the bottom of any page or post on your site running on the Genesis Framework and you’ll find the Layout Settings metabox. It looks like this:

Genesis Layout Settings

If you don’t see Layout Settings on your Genesis post or page, scroll up to the tip top of your page and look for the Screen Options tab on the right. Make sure Layout Settings is checked!

Next we need to specify a name for our custom body class. You can name it anything, just don’t be too generic. I’m calling mine “special-page.”

After you’ve entered your body class, save your post/page and go view it in a browser. A little check of the source code shows that my custom body class (“special-page”) has been added:

Custom Body Class

Now we’re ready to add some CSS that targets this specific page.

Step 2: Add Custom CSS to change the width of your Page

This solution is so easy, you’ll wanna slap your momma. Actually no, don’t slap your momma. But it is easy!

Use the custom body class we created to target the sidebar and content widths on this specific page, like this:

.special-page #sidebar {display: none;}
.special-page #content {width: 85%;}

The first line made the primary sidebar invisible, like Wonder Woman’s invisible jet. The second line tells the content area to scooch on over and take up more room. I went with 85% because it worked with my design, but you could play with that number.

Here’s the result:

Full Width Content

That’s all I’ve got

I don’t know if this officially qualifies as a Genesis Theme Tutorial since my solution is a hack, but it works! If you have a different solution for accomplishing the same layout, please leave a comment below!

43 thoughts on “Genesis Theme Tutorial: Get Rid of the Primary Sidebar (but Keep the Secondary!)”

  1. Hi, I’m trying to do this. I’ve got the custom body class on the post, and have put the code as shown into the child theme css style sheet at the bottom. I’m not seeing any change. Am I putting the code in the wrong place? Thanks!

Leave a Comment

Your email address will not be published. Required fields are marked *

Carrie Dils uses Accessibility Checker to monitor our website's accessibility.