动态更改WordPress主题

如何设置标签以动态更改wordpress当前显示的主题?

我了解此处的类似问题中所述的开关功能:使用多个模板显示页面内容-WordPress, 但我不知道如何实现更改。是否应将开关添加到主题内或主题文件夹内的index.php中?我的链接指向index.php文件吗?

我想在没有插件的情况下执行此操作。

已经执行此操作的站点的示例:www.envye.com/wordpress/

谢谢!


#1


在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');

#2


你可以使用switch_theme()方法。 https://codex.wordpress.org/Function_Reference/switch_theme

来源:

https://www.srcmini02.com/65029.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37356.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?