Meta Box
$wp_registered_sidebars is showing an empty array (3 posts)

  1. sakib000
    Posted 2 years ago #

    Hello, I am trying to load array $wp_registered_sidebars in my select box but I have no idea why this variable which returns array of sidebar, returning an empty array.

    When same variable is called from template files its returning sidebar array as expected.

    Please help.


  2. aryanduntley
    Posted 2 years ago #

    I'm discovering this issue as well. I have worked around the issue previously by calling get_option( 'sidebars_widgets' ), but this will only allow me to display the id's to the user. That isn't cool especially when the id's can be unintuitive at times. Now I've got some time to look into the matter and believe that I have been calling it before the widgets.php file is called (and all of it's associated hoods and functions, eg. -register_sidebar-). So, global variable must be called within a function that fires after the widget hooks. I believe this has to be done within the callback function for add_metabox (in my case because I'm attempting to get this global var in the edit.php file so I can display a list of sidebars for the user to select per page). Can't verify at this second if it will work because client's dev server just crashed, but if I find the answer I will post back to this thread. I know it's been 6 months, sucks when you don't get responses to your inquiries. Hope this comes as new info to you and info you can still use.

  3. aryanduntley
    Posted 2 years ago #

    Server back up. Called gobal $wp_registered_sidebars from inside of the callback for add_metabox. Works like a charm.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.