here is no specialized hook for this. However the hook switch_theme
should work for you.
/**
* Switches current theme to new template and stylesheet names.
*
* @since unknown
* @uses do_action() Calls 'switch_theme' action on updated theme display name.
*
* @param string $template Template name
* @param string $stylesheet Stylesheet name.
*/
function switch_theme($template, $stylesheet) {
update_option('template', $template);
update_option('stylesheet', $stylesheet);
delete_option('current_theme');
$theme = get_current_theme();
do_action('switch_theme', $theme);
}
So you should write custom function that deactivate the theme via hook and activate back, if your done with your task.
add_action('switch_theme', function($theme){
if ( 'Your_Theme_Name' == $theme )
{
// do something.
}
// do others.
return;
});
Related Posts:
- disable active plugins for specific theme
- add_action in functions.php, do_action in plugin?
- Deactivate Plugin on Theme Switch
- Hooking in to replace the Sidebar/Widget areas
- How to get menu location in wp_update_nav_menu hook
- Hooking into the HTML header container
- wp_login_form() ignoring login_form action hook
- How to check if a theme is active?
- how to get path to images in the uploads folder to be used in a plugin
- Preventing a plugin from updating
- How can I have two different urls for the same page that load two different templates?
- How to enable edit button in the theme’s customize UI?
- Ship plugin with a custom theme
- How to solve a conflict between a plugin and a theme?
- WP Config for FTP credentials
- WordPress error – PHP Fatal error: Uncaught Error: Call to undefined function register_block_type_from_metadata()
- why does the add_action(‘the_content’) overwrite my page
- Fatal error: Class not found in
- Showing Notifications While Activating Plugin
- Workflow and best practice for documentation [closed]
- Put code into body tags near top, using a plugin
- Can I share predefined fonts from theme_support with a gutenberg component?
- How can I measure the performance of any WordPress Plugin or Theme?
- Hook before & after plugin / core update
- get_plugins() doesn’t work after plugins_loaded
- Implement plugins as part of a theme
- Are there hooks for WordPress updates?
- Theme or Plugin: Where should I write my code?
- Plugin activation hook in an abstract class
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- Do I still need a theme to use page builders?
- Can I make a super plugin that also has a theme?
- Is there an earlier hook than login_head or login_enqueue_scripts?
- Gravity Forms plugin: How to use “gform_editor_js” action hook? [closed]
- Prevent WordPress installing plugins and themes via Admin
- Plugin Handle URL With Custom Theme
- Map a custom id to wordpress post id
- Check for security updates
- Calling plugin function inside custom plugin for onclick event
- Plugin-generated pages use Not Found or Pages Archive templates?
- All sites themes functions.php have been changed
- “No Add Button” for me to customize my WordPress with themes and pluggins
- How can I list all installed plugins/themes/versions from CLI/API?
- Add sub menu page in your plugin
- how to change automatic placing of social plugins below content?
- Why does my file_exist check fail?
- Deactivate JS Script in Plugin Shortcode
- How to protect WordPress from security scanner [closed]
- how can I query all wordpress users of a blog
- Adding Plugin Assets to Header
- What are admin hooks
- Is it possible not to load theme on a specific page in wordpress?
- I receive taxonomy id
- How to use filter to disable adding a product to wishlist?
- How to extract a .wp-env.json or composer.json containing plugin versions from a production website?
- How to include files relative to a file’s directory
- Function added to hook “new_to_publish” not executing – custom plugin
- Blocking Plugin Css to load custom in template directory
- After a manual update, themes and plugins that were installed (and still in the directory) are not being seen
- Display WordPress comments before the plugins?
- Mobilepress fails to translate short codes
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- Use a hook or filter, or overwrite this Gamipress function?
- Hook from plugin doesn’t fire up from external PHP script
- How to override any plugin file in the child theme
- Replace old theme that understand old css (vcex_icon_box css_animation)
- Is there a hook similar to “save_post” which only fires AFTER the post is completely published?
- Mobile Menu and Mobile Sidebar missing
- save_post hook partly firing in update post
- custom fields not displaying on wordpress site
- How to get a post views count using ‘WordPress popular posts’ plugin
- Show post object of any page in frontend
- Can’t add new plugin or themes on a wordpress multisite network from the primary site as administrator. Error: ERR_TOO_MANY_REDIRECTS
- How to prevent redoing get_posts queries and make results available to other scripts?
- Use action, filter, or hook to append HTML to WordPress plugin function
- Passing function into add_action always returns the first argument
- Hook to display element as product on category page
- WordPress panel is not loading after plugin activated with error: HTTP ERROR 500
- Cron job emails blank
- How can I add a custom checkbox / radio button on the admin theme options to display a CSS or other?
- How to fix On “An unexpected error occurred” message when I click on Add new theme or plugin?
- How to display post by date written (1974) and not date published (today)?
- Images is not showing after migration
- Child Theme Changes Are Not Reflecting In Parent Theme
- Input gets deleted/overwritten after changing to different Admin Menu
- Theme specific plugin, how?
- Variable scope in plugin outside loop [closed]
- Run WP inside a other Site without using frames
- Breadcrumb is not generating the correct post page url
- Display static pages instead of category, in code
- Checking url from plugin [duplicate]
- Theme causing SSL break on chrome
- User register hook can’t access form request
- Install theme as part of a plugin
- Divi Template A Few Questions
- Trying to use wp_register_script/style and enqueu them from an array – getting an error [duplicate]
- Real estate schema markup not showing up on Rich Results test
- Change social icon in twenty twenty three theme
- Convert from Portfolio post to WooCommerce products [closed]
- What’s the best way to update my WordPress theme to Elementor?