WordPress Snippets at WPcustoms

Register Widgets and Sidebars

Register custom theme sidebars and widgets. If you want to init a custom widget you can enable that with the register_widget function


/**
 * Snippet Name: Register Widgets and Sidebars
 * Snippet URL: http://www.wpcustoms.net/snippets/register-widgets-and-sidebars/
 */
 function wpc_widgets_init() {
  // Sidebars
  register_sidebar(array(
    'name'          => __('Primary', 'roots'),
    'id'            => 'sidebar-primary',
    'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => __('Footer', 'roots'), 'id' => 'sidebar-footer', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); // Widgets register_widget('YOUR_CUSTOM_WIDGET_CODE'); } add_action('widgets_init', 'wpc_widgets_init');