Title: Activate widgets using PHP?
Last modified: August 20, 2016

---

# Activate widgets using PHP?

 *  Resolved [lieutenantdan](https://wordpress.org/support/users/lieutenantdan/)
 * (@lieutenantdan)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/activate-widgets-using-php/)
 * Is there a way to turn on and place widgets using PHP or does WP have a function?
   I’m trying to have specific widgets load when the user activates my theme.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [lieutenantdan](https://wordpress.org/support/users/lieutenantdan/)
 * (@lieutenantdan)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/activate-widgets-using-php/#post-3338344)
 * Ok so I’ve limited it to the widgets that wont load are the multi instance ones.
   Not sure if that helps
 *  Thread Starter [lieutenantdan](https://wordpress.org/support/users/lieutenantdan/)
 * (@lieutenantdan)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/activate-widgets-using-php/#post-3338398)
 *     ```
       /*************************************************************************************
        *	Set default widgets
        *************************************************************************************/
   
       // widget instances
       update_option( 'widget_search', array( 2 => array( 'title' => 'Search!' ), '_multiwidget' => 1 ) );
       update_option( 'widget_recent-posts', array( 2 => array( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
       update_option( 'widget_recent-comments', array( 2 => array( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
       update_option( 'widget_archives', array( 2 => array( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
       update_option( 'widget_categories', array( 2 => array( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
       update_option( 'widget_meta', array( 2 => array( 'title' => '' ), '_multiwidget' => 1 ) );
   
       // widget order
       update_option( 'sidebars_widgets', array(
       	'sidebar' => array(
       		'custom_menu_widget_1',
       		'recent-posts-2',
       		'archives-2',
       		'tags_widget_1',
       		'social_network_widget_1',
       	),
       	'wp_inactive_widgets' => array(),
       ));
       ```
   
 * Got an answer…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Activate widgets using PHP?’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 1 participant
 * Last reply from: [lieutenantdan](https://wordpress.org/support/users/lieutenantdan/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/activate-widgets-using-php/#post-3338398)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
