Genesis: 3 Ways To Remove The Primary Sidebar From Single Pages

This post shows you 3 ways to remove the primary sidebar widget area from single pages only.

The reason i wrote this post is to answer this forum question:

How do I unregister the default primary sidebar widget on single pages?

You can:

  1. Add CSS code to your child themes style.css file
  2. Add a custom function with conditional tag to your child themes functions.php file
  3. Create a new page.php file using the WordPress Template Hierarchy and add the remove_action for the sidebar.

CSS

Paste the CSS before the start of your Media Queries in your child themes style.css file.

.page-template-default .sidebar-primary {
display: none;
}

Custom Function

Simply copy the PHP code from the view raw link in the Gist and paste it at the end of your child themes functions.php file.

You may need to modify the conditional checks to suit your needs.

Page Template File

  1. Create a new file using a code editor like Notepad++
  2. Copy the PHP code from the view raw link in the Gist
  3. Paste the code into the new file and upload it to your child themes root directory

Please refer to the WordPress Template Hierarchy for more information.

Related Tutorials

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.