wp-content » themes » functions.php » How to Show Different Themes to Logged-in Users in WordPress

How to Show Different Themes to Logged-in Users in WordPress

In this example, we’ll use the is_user_logged_in() to display a different theme on our website for visitors:

if(is_user_logged_in()) {
    function wpxss_set_my_custom_theme() {
    //replace your theme name here
    return 'your-theme-name';
     }
     add_filter( 'template', 'wpxss_set_my_custom_theme' );
     add_filter( 'stylesheet', 'wpxss_set_my_custom_theme' );
}
else {
// leave the default theme active for visitors
}

The template and stylesheet filters are responsible to select the activated theme for the logged-in users.

Here we set the returning theme name for logged-in users to your-theme-name which you can change to your desired theme name.

Then simply add the above snippet to your custom plugin or child theme.

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended