Dynamically change Wordpress Theme

后端 未结 2 1770
北海茫月
北海茫月 2021-01-26 06:38

How can I set an a tag to dynamically change the theme currently being displayed by wordpress?

I understand the switch function as described in a similar question here:

相关标签:
2条回答
  • 2021-01-26 06:48

    You can use the switch_theme() method. https://codex.wordpress.org/Function_Reference/switch_theme

    0 讨论(0)
  • 2021-01-26 06:57

    Use this in function.php

    function fxn_change_theme($theme) {
    
      if( $condition == true )
        $theme = 'twentytwelve';
      else
        $theme = 'twentyteleven';
    
      return $theme;
    }
    
    add_filter('template', 'fxn_change_theme');
    add_filter('option_template', 'fxn_change_theme');
    add_filter('option_stylesheet', 'fxn_change_theme');
    
    0 讨论(0)
提交回复
热议问题