WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am registering sidebars automatically for each category (a separate widget space per category). The technique I'm using is here.

In the admin side I have an options page where I need to display a dropdown of all registered sidebars... Is there are way to dynamically get this list of registered sidebars? since they're being registered in functions.php I assume they're in memory, not in the database.

I could keep track of the sidebars I register in some global variable, but just in case plugins register their own sidebars, I'd like to account for them too.

I'll dig through the core if I have to, but thought someone might know off-hand:)


share|improve this question
up vote 15 down vote accepted

Hmm... I'm not sure if this is the best way to do it but it's simple:

I looked in register_sidebar() and found that new sidebars are simply tacked onto an array:$wp_registered_sidebars

And I guess that's that. If they ever change the name of the variable, I guess I'd be screwed.

share|improve this answer
You can always access it via $GLOBALS['wp_registered_sidebars']. In case that changes, you can in your plugin just run a search and replace - and it didn't change since it has been introduced as far as I can remember. – hakre Jan 1 '11 at 23:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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