Site icon WP Smith

How to Filter the Genesis Sidebar Defaults

By default, Genesis registers its sidebars. For styling reasons, we may want to filter those; however, this can prove difficult with Genesis if you don't understand how Genesis calls the various files and their order. WordPress follows this priority order:

  1. Plugins
  2. Child Theme
  3. Parent Them

First, WordPress gives prioirity to plugins, so modifying these defaults works well in a core functionality plugin.

Second, Genesis "teaches" many people to place their content below the statement require_once( get_template_directory() . '/lib/init.php' ) that often appears at the top of the functions.php file. In essence, by doing this you are executing genesis_init and genesis_setup hooks. So anything that hooks to those functions that appear below (and even before) this statement WILL NOT be executed.

So, let me demonstrate:

THIS WILL NOT WORK!

So, the way I build my child themes is to use functions for everything, so there is no dropping in code in functions.php, like so many do (and even as WordPress and Genesis encourages). While Genesis can do things like add_theme_support(), or genesis_register_sidebar(), etc. These are best placed inside a function that hooks to genesis_setup, genesis_init, or after_setup_theme. However, this is more about the philosophy and the praxis of child theme development.

So, if you use your functions.php as most people do, my recommendation is to either (1) add this to your core functionality plugin, or (2) develop another plugin (drop-in [plugin file that is placed in wp-content/plugins directly, see also hakre on wordpress's (sic) post on Must-Use Plugins and Drop-Ins] even). To help you, here is the plugin code you will need:

Or you can download it here: [download id="20"]

Once you download the file, just upload and install just like you would any other plugin.