Tutorials, Wordpress

How to add dynamic sidebar in wordPress?

21 January 2019

Dynamic Sidebar can be added to your theme in the functions.php file, using the register_sidebar() function. we will add dynamic sidebar to wordPress.

These widget areas are found in the admin area under Appearance > Widgets.

For Example:
Step 1:

add_action( 'widgets_init', 'my_register_sidebars' );

function my_register_sidebars() {
        'id' => 'new_sidebar',
        'name' => __( 'New Sidebar' ),
        'description' => __( 'A short description of the sidebar.' ),
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>'

Using A Dynamic Sidebar In Your Theme:
Step 2:
 <div class="sidebar new-sidebar">
      <?php dynamic_sidebar( 'new_sidebar' ); ?>
Output here:

Leave a Comments