Skip to content

Instantly share code, notes, and snippets.

@prosantamazumder
Last active April 27, 2020 21:11
Show Gist options
  • Save prosantamazumder/b84889b002a601b9da51ae4f5d63b5b3 to your computer and use it in GitHub Desktop.
Save prosantamazumder/b84889b002a601b9da51ae4f5d63b5b3 to your computer and use it in GitHub Desktop.
Register Sidebar / Widgets
//Code added Function.php
function wpb_widgets_init() {
register_sidebar( array(
'name' => __( 'Main Sidebar', 'wpb' ),
'id' => 'sidebar-1',
'description' => __( 'The main sidebar appears on the right on each page except the blog page', 'wpb' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'wpb_widgets_init' );
//display front end where you need sidebar
<?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment