动态更改 Wordpress 主题 [英] Dynamically change Wordpress Theme
问题描述
如何设置a标签以动态更改wordpress当前显示的主题?
How can I set an a tag to dynamically change the theme currently being displayed by wordpress?
我理解这里的类似问题中描述的开关功能:显示页面使用多个模板的内容 - WordPress ,但我不知道如何实施更改.应该将开关添加到主题内的 index.php 还是主题文件夹内?我的链接是否指向 index.php 文件?
I understand the switch function as described in a similar question here: Display page content using multiple templates - WordPress , but I don't know how to implement the change. Should the switch be added to index.php inside a theme, or inside the theme folder? Does my link point to the index.php file?
如果可能的话,我想在没有插件的情况下做到这一点.
I would like to do this without a plugin if possible.
已经这样做的网站示例:www.envye.com/wordpress/
An example of a site which does this already: www.envye.com/wordpress/
谢谢!
推荐答案
在 function.php 中使用这个
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');
这篇关于动态更改 Wordpress 主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!