2010-02-27 209 views

回答

3

更新current_theme选项:

update_option('current_theme', '[theme name]'); 

为了获得主题的名称使用:

$themes = get_themes(); 
+0

谢谢哈门。我很感激! – 2010-02-27 17:10:34

1

在当前版本的WordPress 3.4.2您需要更新3个选项,切换到另一个主题(minihyper - 在我的情况下)

update_option('template', 'minihyper'); 
update_option('stylesheet', 'minihyper'); 
update_option('current_theme', 'Mini Hyper'); 

前两个选项是关键,第三个是真的没有除了也许你可以在代码的某个地方使用这个选项来显示当前的主题名称。

更新:

这是一个正确的方法:

<?php switch_theme($template, $stylesheet) ?> 

例与minihyper:

<?php switch_theme('minihyper', 'minihyper') ?>