Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[WordPress] Programmatically deactivate widgets upon theme activation
add_action( 'after_setup_theme', 'acme_remove_default_widgets' );
* When the theme is activated, all of the active widgets are deactived.
* @since 1.0.0
function acme_remove_default_widgets() {
if ( ! get_option( 'acme_cleared_widgets' ) ) {
update_option( 'sidebars_widgets', array() );
update_option( 'acme_cleared_widgets', true );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment