Below is a custom WordPress plugin that will switch to any theme only on the front page. In this example, only the front page will switch to use the Twenty Twenty Three theme. Make sure the theme exists in your /themes/ directory when testing your custom plugin.
ThemeSwitcher Pro works with custom code to easily create your own custom conditionals and manage via code. The plugin example code is located at https://github.com/WebDevStudios/theme-switcher-pro-add-ons. Copy the plugin code to your /plugins/ directory and customize away!
<?php
/**
* Plugin Name: ThemeSwitcher FrontEnd Addon
* Plugin URI: https://webdevstudios.com
* Description: Switch to theme if on the front-page.
* Version: 0.1.0
* Author URI: https://webdevstudios.com
*/
/**
* Example demonstrating how to add custom theme switching conditions.
*
* 1. Ensure that the ThemeSwitcher Pro plugin is installed and activated.
* 2. Copy this file to your wp-content/plugins directory then activate it.
* 3. Make sure that the themes referenced below are active in your install,
* (twentytwentyone, twentytwentytwo, and twentytwentythree)
* or change the example code so that it references your installed themes.
* 4. Check out the themeswitcher-pro/inc/helper-functions.php file for helper functions.
*
* @return void
*/
function tsp_conditions() {
if ( ! class_exists( 'TSP_Manager' ) ) {
return;
}
/**
* Switch to theme if on the front-page.
* @since 0.1.0
* @see helper-functions.php
* @see TSP_Manager
* @see tsp-manager.php
*/
TSP_Manager::register(
'twentytwentythree', // Theme slug goes here.
function () {
return tsp_is_front_page(); // Use instead of is_front_page().
},
1 // This Priorty must be set to 1.
);
}
add_action( 'plugins_loaded', 'tsp_conditions', 100 ); // Use priority of 100.