• I’m trying to switch themes when a user uses a mobile phone to browse the page. at first, the switch_theme() function seems like the way to go, but since it uses update_option to change the theme, my guess is that the change is permanent.

    Is there a way to just load a specific theme depending on the users browsers? I already have the mobile detection done, I don’t suppose I can use something like add_filters()?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter charlesolaes

    (@charlesolaes)

    Maybe I should rephrase my question. Will something like add_filter( 'template', 'my_function' ); Load my specified template like switch_theme but without using update_option? or do I have to apply filters to hooks like home_template or page_template or stylesheet for the template to load the theme?

    Thread Starter charlesolaes

    (@charlesolaes)

    I don’t know how to edit my older posts so I guess it’ll be ok to post another…

    I can’t seem to apply filters to my home_template, I have tried returning the full url and/or real path for the call back function but it just wouldn’t take.

    add_filter('home_template', 'my_function');
    
    myfunction(){
       return 'www.example.com/pathtotemplate/templatename/home.php';
      //i've also tried returning the real path ie: C:/var/www etc...
    }

    The codex says,

    Each of these filters takes as input the path to the corresponding template file in the current theme.

    I’m not really sure what I’m doing wrong here. add_filter(‘stylesheet’, ‘myfunction2’); overrides the stylesheet correctly but I can’t seem to get the template file changed.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘switching templates for mobile’ is closed to new replies.