1/**
2 * Add a sidebar.
3 */
4function wpdocs_theme_slug_widgets_init() {
5 register_sidebar( array(
6 'name' => __( 'Main Sidebar', 'textdomain' ),
7 'id' => 'sidebar-1',
8 'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'textdomain' ),
9 'before_widget' => '<li id="%1$s" class="widget %2$s">',
10 'after_widget' => '</li>',
11 'before_title' => '<h2 class="widgettitle">',
12 'after_title' => '</h2>',
13 ) );
14}
1<?php if ( is_active_sidebar( 'your-sidebar-slug' ) ) { ?>
2 <ul id="sidebar">
3 <?php dynamic_sidebar('your-sidebar-slug'); ?>
4 </ul>
5<?php } ?>