Skip to content

Instantly share code, notes, and snippets.

@eddiemoya
Last active October 4, 2015 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddiemoya/2562465 to your computer and use it in GitHub Desktop.
Save eddiemoya/2562465 to your computer and use it in GitHub Desktop.
Basic Widgetized Areas
<?php ## functions.php
/**
* This 'registers' the sidebar and tells WordPress it exists, as well as names it
* and gives it wrapping markup for each widget, and the title if applicable.
*
* Change the markup to meet your needs.
*/
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => 'Hero',
'description' => 'Hero section of the theme',
'before_widget' => '<div class="widget %2$s" id="%1$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>'
));
}
## whatever template your sidebar needs to be in.
/**
* This implements the sidebar, the string you pass should be the 'name' from when
* it was registered.
*
* The purpose of the wrapping condition is to allow for default content in case no
* widgets are added to the sidebar.
*/
if ( !dynamic_sidebar('Sidebar') ) {
//default stuff that will be overridden if there is anything in the sidebar.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment