2016-07-22 93 views
0

我試圖設置子主題路徑。我不想從標準位置加載子主題模板,而是想從其他位置加載它們。如何設置子主題路徑

比如我的主題:

wp-content/themes/twentyfifteen 
wp-content/themes/twentyfifteen_child 

其中twentyfifteen_child具有的style.css和functions.php中有任何覆蓋模板一起。這是工作正常,但我想以編程方式將兒童主題路徑設置爲此代替︰

wp-content/themes/twentyfifteen_child/twentyfifteen_grandchild 

這可能嗎?

回答

0

我只是想出了答案,儘管可能有更好的方法來做到這一點。我在functions.php中嘗試了以下內容,但沒有奏效。但是,如果我在插件中添加相同的東西,它就可以工作。

add_filter('stylesheet_directory', 'custom_stylesheet_directory'); 
function custom_stylesheet_directory($dir) 
{ 
    $project = $dmmEnv->getProject(); 
    $dir = str_replace(
     'twentyfifteen_child' , 
     'twentyfifteen_child/twentyfifteen_grandchild', $dir); 

    return $dir; 
}