Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:58:42+00:00 2026-06-14T21:58:42+00:00

Is it possible to switch the WordPress theme programmaticly? For example when there is

  • 0

Is it possible to switch the WordPress theme programmaticly? For example when there is a certain browser (found a plugin to detect that) that another theme is used?

I want to be able to give outdated browsers (IE7 and lower, lower than Saf and FF 3 e.d.) and mobile browsers a different theme than the other browsers.

I found the method switch_theme however that does not do the thing I expect (I get an blank error when I call this in functions.php) like

switch_theme('twentyten', 'stylesheet');

Or am I using this method wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:58:43+00:00Added an answer on June 14, 2026 at 9:58 pm

    Had you searched WordPress StackExchange, you would have found this:

    add_filter( 'template', 'wpse_49223_change_theme' );
    add_filter( 'option_template', 'wpse_49223_change_theme' );
    add_filter( 'option_stylesheet', 'wpse_49223_change_theme' );
    
    function wpse_49223_change_theme($theme) 
    {
        if ( wp_is_mobile() ) 
            $theme = 'twentyten';
    
        return $theme;
    }
    

    wp_is_mobile is a built-in WordPress function, reproduced bellow:

    function wp_is_mobile() {
        static $is_mobile;
    
        if ( isset($is_mobile) )
            return $is_mobile;
    
        if ( empty($_SERVER['HTTP_USER_AGENT']) ) {
            $is_mobile = false;
        } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false // many mobile devices (all iPhone, iPad, etc.)
            || strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false
            || strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/') !== false
            || strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle') !== false
            || strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false
            || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false ) {
                $is_mobile = true;
        } else {
            $is_mobile = false;
        }
    
        return $is_mobile;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: C# - Is there a better alternative than this to ‘switch on
Is that possible to switch an Open Source Project license from GPL to LGPL
Is it possible to switch input language for another application? Having application's process ID,
Is it possible to switch the browser into and out of full screen mode
In Eclipse, is it possible to switch an application that is Run ning (
Is it possible to switch workspaces in Eclipse without relaunching the application? I want
Possible Duplicate: How to switch an Application between Themed and not Themed at run-time?
Possible Duplicate: Is it safe to assume strict comparison in a Javascript switch statement?
Is it possible from a keyboard shortcut to switch from the XCode editor window
Possible Duplicate: Why can't variables be declared in a switch statement? How can a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.