Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#23934 closed defect (bug) (wontfix)

Calling sidebar two times, widgets have the same ID

Reported by: alexvorn2's profile alexvorn2 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Widgets Keywords:
Focuses: template Cc:

Description

If we call in the Twenty Thirteen the function of the sidebar

<?php dynamic_sidebar( 'sidebar-2' ); ?>
<?php dynamic_sidebar( 'sidebar-2' ); ?>

then the widgets ids from each sidebars are the same.

Change History (6)

#1 @alexvorn2
11 years ago

this is not valid to have the same id two or more times

#2 @SergeyBiryukov
11 years ago

  • Component changed from General to Widgets

#3 @ocean90
10 years ago

  • Focuses template added
  • Keywords reporter-feedback close added

Why would someone call a sidebar twice on a page?

#4 @alexvorn2
10 years ago

for example you want to show the same widget area in the header and in the footer, a widget that shows recent posts.

#5 @Ipstenu
10 years ago

  • Keywords reporter-feedback removed

Thanks for the report alexvorn2. Sorry you never got a response for so long.

While you're certainly correct that the ID shouldn't be reused, the use-case of someone calling the same widget-area twice is exceptionally rare (and possibly not permissible for acceptance into the wporg theme repository). I suggest this as wontfix since the proper (and expected) use would be to not reuse a widget area on the same page. I could see footer1 (show only on pages) and footer2 (show only on posts) but plugins like widget visibility seem more appropriate for that.

Basically this error would be as expected, you're calling the same sidebar twice.

Plugin that may help you here: http://wordpress.org/plugins/duplicate-widget/

#6 @obenland
10 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Agreed, themes should always use multiple sidebars for multiple widget areas. It should be the user's decision if they want to show the same widget in more than on location.

Note: See TracTickets for help on using tickets.