• Resolved do77

    (@do77)


    Hey there!

    So I want to have three sidebars to display different content depending on the page. The first sidebar works fine. However, when I add the text widget to the second sidebar (or the third) and then reload the widgets page, the text widget is disappeared from the sidebar again. This is what I did:

    functions.php

    if ( function_exists('register_sidebar') )
    
    register_sidebar(array(
      'id' => '1',
      'name' => 'sidebar1',
      'description' => 'Content will appear in the right header',
      'before_widget' => '',
      'after_widget' => '',
      'before_title' => '<h2>',
      'after_title' => '</h2>'
    ));
    
    register_sidebar(array(
      'id' => '2',
      'name' => 'sidebar2',
      'description' => 'Content will appear in the right header',
      'before_widget' => '',
      'after_widget' => '',
      'before_title' => '<h2>',
      'after_title' => '</h2>'
    ));
    
    register_sidebar(array(
      'id' => '3',
      'name' => 'sidebar3',
      'description' => 'Content will appear in the right header',
      'before_widget' => '',
      'after_widget' => '',
      'before_title' => '<h2>',
      'after_title' => '</h2>'
    ));

    In sidebar.php

    <?php if (is_page('2') ): ?>
    <?php dynamic_sidebar( '1' ); ?>
    <?php elseif (is_page('9') ): ?>
    <?php dynamic_sidebar( '2' ); ?>
    <?php elseif (is_page('11') ): ?>
    <?php dynamic_sidebar( '3' ); ?>
    <?php endif; ?>

    and then I am calling the sidebar in the header with
    <?php get_sidebar() ?>

    Any idea what I am doing wrong? Why can I only add the text widget to the first sidebar? Basically, I can add the widget also to the other two sidebars but it won’t stay there.

    Many thanks in advance!!

Viewing 1 replies (of 1 total)
  • Thread Starter do77

    (@do77)

    Solved the problem. For some reason the fact that I used ID and Name in the registration of the sidebars created the weird behaviour. After deleting ID it worked!

Viewing 1 replies (of 1 total)

The topic ‘Problem adding text widget to three registered sidebars’ is closed to new replies.