Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:)

Thanks

share|improve this question

1 Answer 1

up vote 13 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
3  
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

 
discard

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.