2012-10-01 53 views
0

我已經基本上最高審計機關轉到主題文件夾,然後去看看這個目錄,這條道路的功能,它使用:加載子主題文件

get_template_directory() 

,但它似乎正在尋找對於父主題中的所述文件,是否有與兒童主題相同的內容 - 要僅在您自己的目錄中查看,而不是父主題目錄

回答

0

get_template_directory();正在尋找父主題。 (家長是一個「模板」,兒童主題的是......嗯......「孩子主題」)

使用<?php get_stylesheet_directory_uri(); ?>代替,或

<?php 
$theme = get_bloginfo('stylesheet_directory'); 
echo = $theme; 
?> 

或在你的functions.php文件,你可以做些什麼像

define('CHILD_DIR', get_stylesheet_directory()); 

然後圖像或東西,你可以做

printf(CHILD_DIR.'/images/image.jpg'); 

EDIT

Here's the source一些的那個,並注意3或第4款

在事件被使用的子主題,這個函數將返回孩子的主題目錄URI。如果你想要父目錄,可以使用get_template_directory_uri()。