Skip to content

Instantly share code, notes, and snippets.

@Edwardtonnn
Created August 3, 2018 16:30
Show Gist options
  • Save Edwardtonnn/4c8f37a827dd5a5726c7bb410feeeb3c to your computer and use it in GitHub Desktop.
Save Edwardtonnn/4c8f37a827dd5a5726c7bb410feeeb3c to your computer and use it in GitHub Desktop.
Adds multiple sidebars to any theme for WordPress
<?php
// Adds Widget Area
// Register Widgets
function custom_sidebar() {
register_sidebar(array(
'id' => 'my-new-widget',
'name' => __( 'My New Widget', 'text_domain' ),
'description' => __( 'This is my widget description.', 'text_domain' ),
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
));
register_sidebar(array(
'id' => 'my-new-widget-2',
'name' => __( 'My New Widget 2', 'text_domain' ),
'description' => __( 'This is my widget description.', 'text_domain' ),
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
));
}
add_action( 'widgets_init', 'custom_sidebar' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment