1
function Y_widget_register(){
 register_sidebar(array(
     'name'=>esc_html__( 'Sidebar', 'Y-07' ),
     'id'=> 'y-sidebar',
     'description'=>'Dynamic Right Sidebar',
    'before_widget' => '<section id="%1$s" class="y-widget %2$s">',
        'after_widget'  => '</section>',
     'before_title'  => '<h2 class="y-widget-title">',
     'after_title'   => '</h2>'


  ) );
}


add_action('widgets-init','Y_widget_register' );

I tried different styles previous versions too but not working, what possibilities making my code not to work.

1 Answer 1

1
add_action( 'widgets_init', 'Y_widget_register' );

You have a typo - use underscores.

Here is the working piece:

function Y_widget_register() {
register_sidebar(array(
    'name' => esc_html__('Sidebar', 'Y-07'),
    'id' => 'y-sidebar',
    'description' => 'Dynamic Right Sidebar',
    'before_widget' => '<section id="%1$s" class="y-widget %2$s">',
    'after_widget' => '</section>',
    'before_title' => '<h2 class="y-widget-title">',
    'after_title' => '</h2>'
));
}

add_action('widgets_init', 'Y_widget_register');
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.