Skip to content

Instantly share code, notes, and snippets.

@vivek-kumar-poddar
Created September 2, 2017 15:40
Show Gist options
  • Save vivek-kumar-poddar/8b317c54cc6afddac448807ef183aa89 to your computer and use it in GitHub Desktop.
Save vivek-kumar-poddar/8b317c54cc6afddac448807ef183aa89 to your computer and use it in GitHub Desktop.
This code snippet will help you to register a new widget in wordpress. For more details please visit: https://wpvkp.com/create-new-widget-area-in-wordpress
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function bb_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'bb' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'bb' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'bb_widgets_init' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment