Skip to content

Instantly share code, notes, and snippets.

@talentedaamer
Created November 25, 2015 08:31
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 talentedaamer/68bccfe45eae395cd9c9 to your computer and use it in GitHub Desktop.
Save talentedaamer/68bccfe45eae395cd9c9 to your computer and use it in GitHub Desktop.
Register widget areas or sidebars in WordPress using register_sidebar() function
<?php
/**
* widgets_init action hook.
* used to register, widgets or widget areas in a theme.
*/
add_action( 'widgets_init', 'oopthemes_widgets_init' );
function oopthemes_widgets_init() {
register_sidebar( array(
'name' => __( 'Primary Sidebar', 'theme-slug' ),
'id' => 'sidebar-primary',
'description' => __( 'Description of the Primary sidebar.', 'theme-slug' ),
'before_widget' => '<aside id="%1$s" class="primary-widget widget %2$s">',
'after_widget' => '</aside>',
'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