My widget code is not working properly

I am developing themes of WordPress. I am trying to showing the
widget area. In the appearance area my widget option is showing
correctly but in main home screen the widgets are not showing
properly. The widget area showing bullet point on the right side of my template. Please anyone help to solve my code and mention what is the error???

My code

 register_sidebar(array(  
            'name'=> __('Right Hand Sidebar'),
            'id' => 'right-sidebar',
            'description' => __('Widgets in this area will be shown on the right-hand side'),
            'before_title' => '<h2>',
            'after_title' => '</h2>',
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>'   
));

Related posts

1 comment

  1. The below code need to add to theme's functions.php.Id should be unique.You need to hook your custom sidebar under widgets_init hook.
    
    <?php 
    function register_my_widgets(){
    $args = array(
        'name'          => __( 'My Sidebar' ),
        'id'            => 'my-sidebar',
        'description'   => 'This is my sidebar',
            'class'         => '',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget'  => '</li>',
        'before_title'  => '<h2 class="widgettitle">',
        'after_title'   => '</h2>' ); 
         register_sidebar($args);
    
         }
         add_action( 'widgets_init', 'register_my_widgets' );
    ?>
    
    
    After adding code you easily see your custom sidebar in Appearance->Widgets. Now you can add wordpress default widgets or you own.
    
    To fetch the contents of this sidebar to frontend.You need to add the code below.
    
    <?php 
    if ( is_active_sidebar( 'my-sidebar' ) ){
    
        dynamic_sidebar('my-sidebar');
    }
    
    ?>
    

Comments are closed.