I need to add four sidebar widgets that display on designated pages. When I add the code to create the new widgets to the functions.php, it disables the other widgets.

The footer widget, and one of the existing sidebar widgets stops working. They still appear in Appearance -> Widgets, but on the website they stop displaying.

Here is the code I used to add the widget.

if ( function_exists('register_sidebar') ) {
    'name' => 'Sidebar About',
    'id' => 'about-sidebar',
    'description' => 'Sidebar that shows only on the About page',
    'before_widget' => '<li id="%1$s">',
    'after_widget' => '</li>',
    'before_title' => '<h2>',
    'after_title' => '</h2>',


I am worried that my clients website has too many plugins that may interfere with creating new widgets.

  • 1
    You are adding the sidebar, not a widget.
    – Max Yudin
    May 23, 2017 at 7:03

1 Answer 1


You missed a lot of things . You have to add add action hook in your code. In below I give you an ideal widget code. Now try this.Replace your code with mine. Hope it will work. Thanks

    function test_widgets_init() {
    register_sidebar( array(
        'name'          => esc_html__( 'Sidebar', 'test' ),
        'id'            => 'sidebar-1',
        'description'   => esc_html__( 'Add widgets here.', 'test' ),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h2 class="widget-title">',
        'after_title'   => '</h2>',
    ) );
add_action( 'widgets_init', 'test_widgets_init' );
  • I did have the hook, but I left it off in my original post. However, this code seems to have done the trick! Thanks! May 23, 2017 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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