chihung
3/4/2019 - 10:43 AM

SAMPLE REGISTER SIDEBAR IN WORDPRESS

add_action( 'widgets_init', 'theme_slug_widgets_init' );
function theme_slug_widgets_init() {
    register_sidebar( array(
        'name' => __( 'Main Sidebar', 'theme-slug' ),
        'id' => 'sidebar-1',
        'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'theme-slug' ),
        'before_widget' => '<div id="%1$s" class="sidebar-child widget %2$s">',
        'after_widget'  => '</div>',
        'before_title'  => '<h4 class="title-light-gray">',
        'after_title'   => '</h4>',
    ) );
}
<?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
    <?php dynamic_sidebar( 'sidebar-1' ); ?>
<?php endif; ?>