WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 7 months ago

#20360 closed defect (bug) (invalid)

New Sidebar Takes Over Previous Sidebar Widgets

Reported by: imikedesigns Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3.1
Component: Widgets Keywords:
Focuses: Cc:

Description

When creating a new sidebar in a theme already utilizing a sidebar, the new sidebar takes on the widgets of the sidebar previously occupying that place of order. For example, a theme currently has these sidebars, with widgets in use:

Sidebar
Footer

Adding a new sidebar in a array:

$sidebars = array('Home Page Sidebar','Sidebar','Footer');

foreach ($sidebars as $sidebar) {

  register_sidebar(array('name'=> $sidebar,

    'before_widget' => '<article id="%1$s" class="widget %2$s"><div class="container">',

    'after_widget' => '</div></article>',

    'before_title' => '<h3>',

    'after_title' => '</h3>'

  ));

}

Home Page Sidebar takes the widgets of the Sidebar when it takes in place in line.

Change History (2)

comment:1 c3mdigital7 months ago

  • Keywords close added

Unless you are relying on incrementally number named sidebars you should be adding an id to the array.

 * When allowing for automatic generation of the name and ID parameters, keep
 * in mind that the incrementor for your sidebar can change over time depending
 * on what other plugins and themes are installed.

For incremental sidebars you normally just name them Sidebar and the id would be 'sidebar-'.&x

comment:2 SergeyBiryukov7 months ago

  • Component changed from General to Widgets
  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.