Title: Populate sidebar with widgets in php code
Last modified: August 19, 2016

---

# Populate sidebar with widgets in php code

 *  [etsuei](https://wordpress.org/support/users/etsuei/)
 * (@etsuei)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/populate-sidebar-with-widgets-in-php-code/)
 * Hey guys. I’ve hit an epic roadblock and I’m beginning to go crazy.
 * Is there a way to populate a sidebar with available widgets. So for example, 
   say if I create a new custom sidebar and I want to auto populate it with a set
   of widgets (ie. text, tag_cloud).
 * I’ve been trying to trace the steps by looking through the admin-ajax.php and
   rewriting the code in a plugin. Basically mimicing the ajax calls that are done
   from the widgets page.
 * I hit a wall when I’m trying to access the global variables like:
    $wp_registered_widget_updates
   $wp_registered_sidebars $sidebars_widgets $wp_registered_widgets
 * Problem is they’re all empty! However when using ajax they are set. I’ve tried
   including all files and including all actions that the admin-ajax runs and with
   no success.
 * Any help or direction on how to do this would help. Thanks!

The topic ‘Populate sidebar with widgets in php code’ is closed to new replies.

## Tags

 * [Backend](https://wordpress.org/support/topic-tag/backend/)
 * [code](https://wordpress.org/support/topic-tag/code/)
 * [populate](https://wordpress.org/support/topic-tag/populate/)
 * [sidebar](https://wordpress.org/support/topic-tag/sidebar/)
 * [widgets](https://wordpress.org/support/topic-tag/widgets/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [etsuei](https://wordpress.org/support/users/etsuei/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/populate-sidebar-with-widgets-in-php-code/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
