Skip to content

Instantly share code, notes, and snippets.

@anegoda1995
Last active March 14, 2017 08:12
Show Gist options
  • Save anegoda1995/6d0a731cafb7883ab113e95c12e91d1a to your computer and use it in GitHub Desktop.
Save anegoda1995/6d0a731cafb7883ab113e95c12e91d1a to your computer and use it in GitHub Desktop.
Register widget area (sidebar) in WordPress template functions.php file
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function [name_of_theme]_widgets_init()
{
register_sidebar(array(
'name' => esc_html__('Name of widget area', '[name_of_theme]'),
'id' => '[widget_area_unique_name]', //OnLy LoWeRcAsE!!!!!!!!!!!!!!!!!! else not save widgets on area
'description' => esc_html__('Description', '[name_of_theme]'),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment