2010-02-27 208 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') ?>