Themes don’t currently have activation/deactivation/installation/uninstallation hooks.
Your best bet is to “fake” it somehow, perhaps with a function that only executes one time, based on a switch that gets toggled when the function executes. e.g.:
<?php
function wpse45817_theme_activation() {
// globalize our switch
global $wpse45817_theme_activation_switch;
// Check to see if the switch is set
if ( isset( $wpse45817_theme_activation_switch ) ) {
return;
} else {
// EXECUTE YOUR THEME-ACTIVATION CODE HERE
//
//
// Toggle Theme activation switch
$wpse45817_theme_activation_switch = true;
}
}
add_action( 'after_setup_theme', 'wpse45817_theme_activation' );
?>
Related Posts:
- Must activation/deactivation functions in a class be static?
- Viewing output when the “The plugin generated x characters of unexpected output during activation” error is triggered
- Problem creating a table with dbDelta
- Use an activation code to change a role [closed]
- How to let new users login without email activation
- On local machine can’t log in or reset password but I can log in on the live version, user has activation key in database
- Uninstall, Activate, Deactivate a plugin: typical features & how-to
- How To Activate Plugins via Code?
- Activate a plugin through PHPMyAdmin or FTP?
- How to redirect to settings page once the plugin is activated?
- How to check if a theme is active?
- How to run an activation function when plugin is network activated on multisite?
- How to output message during plugin activation
- Prevent network activation of plugin
- Inserting Taxonomy Terms During a Plugin Activation?
- Import WordPress XML File from Within Functions.php
- Does wordpress create activity, update logs?
- Customizing wp-activate.php
- How to Modify/Change a Buddypress/WordPress Account Activation Process
- Pluggable function and activation check?
- __NAMESPACE__ with register_activation_hook
- How to manually activate user in dashboard only by admin
- Login email after registration never sent or received
- Automatically install wordpress plugin at theme activation
- Show a confirm message before plug-in activation
- Using wp_cron with custom time interval and the register activation hook
- Is it possible to stop a theme activation when a certain plugin is not activated
- Send activation email to user after signup [duplicate]
- Multisite: setting theme and options when a new blog is created
- Function to activate WordPress theme inside a plugin
- Can’t add user to blog on registration (Multisite)
- Call activation hook multiple times
- Redirect after User Activation [closed]
- Activate Plugin which is in subfolder?
- Only allow plugin to be activated on root site of multisite
- wpmu_signup_user_notification filter not working
- explanation for activate_plugin function in wordpress core
- Remote plugin activation hook
- Register theme customizer settings when theme activates [duplicate]
- why creating tables using $wpdb is not being executed while installing plugins?
- Ask user permission when activating a plugin
- Force plugin to fail activation
- Override pluggable functions in a plugin?
- Plugin activation error due to unexpected output
- WordPress register_activation_hook table creation not working
- Multisite: Activate plugin for subsites only?
- Customize user account activation message
- The plugin generated x characters of unexpected output, $wpdb not defined
- Correct way to use register_activation_hook
- Cannot run the code after I activate the plugin
- How to create a page when a theme is activated?
- wordpress in nginx docker container connected to php:8-fpm container and mariadb container isn’t creating any tables on plugin activation
- Settings not set after calling register_setting()
- Unable to activate wordpress importer after installing it
- How to include plugin without activation?
- Unexpected Output: register_activation_hook with namespace
- Auto add content such as pages upon plugin activation?
- Detect when any plugin is activated or deactivated
- How to automate wordpress plugin activate and deactivate by php logic?
- How to add custom menu item on plugin activation?
- Comments deactivated
- Default Plugin Settings Not Writing to Database
- is_plugin_active() not properly returning true
- How to properly setup an activation hook
- Plugin won’t activate – cannot declare class (already in use)
- Plugin Deactivate Self on Activation Errors
- How to activate plugins for my WordPress sites from a remote server
- register_activation_hook with include file [closed]
- Prevent a plugin from being automatically activated
- Is any information available in PHP files in WP about plugin activation history?
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- Activated plugin is stored as an object, rather than as a path
- Own plugin corrups plugin-activation
- How do you disable account activation in WPMU and then log the user in right away?
- How to check if tables in WordPress still exists after activations
- How to block plugin activations with no known user or coming from unknown IP address range?
- On multisite, plugins are disabled prematurely when viewing the /wp-activate.php page file
- Run plugins only on certain pages
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Force file download on plugin activation
- What is the correct way of updating wordpress options
- WordPress user account activation
- Display message on homepage when new user account is activated
- Multiple instance of data in plugin custom database table on plugin activation
- Why this function not working for install database on plugin activation
- How do i place same widgets multiple time by default on theme activation?
- register_activation_hook in oop approach
- How to create multiple database tables on plugin activation?
- Run function on plugin activation before plugin is loaded
- register_activation_hook for multiple functions
- How can I create blog specific database table in multisite?
- I have no images in an activated wp theme
- Add Link Category on Activation?
- WordPress Plugin Activate / Deactive Failing
- When a plugin gets updated from the repo, does the “activation” hook fire again?
- How can I manually activate a new site in a wordpress multisite network?
- A question about register_activation hook
- rewrite_rules() not applying rules on plugin activation only after permalinks menu is clicked
- register_activation_hook() not working as expected
- Multiple array for post_content on plugin activation