Call new theme based on condition wp

You want to know how to call a new theme based on a condition in WordPress.

In WordPress, you can use the wp_enqueue_style function to load a theme's stylesheet. To call a new theme based on a condition, you can use the wp_enqueue_style function along with a conditional statement.

Here's an example:

<?php
if ( /* your condition here */ ) {
    wp_enqueue_style( 'new-theme', get_template_directory_uri(). '/new-theme.css' );
} else {
    // Load the default theme
    wp_enqueue_style( 'default-theme', get_template_directory_uri(). '/style.css' );
}
?>

In this example, the wp_enqueue_style function is called with the condition /* your condition here */. If the condition is true, the new-theme.css file is loaded. If the condition is false, the style.css file is loaded.

You can replace /* your condition here */ with any valid PHP condition, such as a check for a specific page, post, or user role.

For example, to load a new theme only on the homepage, you could use:

<?php
if ( is_home() ) {
    wp_enqueue_style( 'new-theme', get_template_directory_uri(). '/new-theme.css' );
} else {
    // Load the default theme
    wp_enqueue_style( 'default-theme', get_template_directory_uri(). '/style.css' );
}
?>