• Resolved lieutenantdan

    (@lieutenantdan)


    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

    (@lieutenantdan)

    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

    (@lieutenantdan)

    /*************************************************************************************
     *	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.