2016-07-22 43 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; 
}