2013-08-26 117 views
0

這是我的代碼,我打電話給我的PHP文件:WordPress的不包括我的PHP文件

<section style="width:100%; height:120px; clear:both;" > 
    <section class="campaign_statistics" style="background-color:#EFEFEF;"> 

     <?php include('progress_chart.php'); ?> 

    </section> 
</section> 

然而,沒有任何顯示,當我把它,並在頁面上,當我查看網頁的源文件,這是什麼我看到:

<section style="width:100%; height:120px; clear:both;" > 
    <section class="campaign_statistics" style="background-color:#EFEFEF;"> 



    </section> 
</section> 

除了我的php之外,其他的都包括在內。所有這些在星期五都工作得很好。我今天早上去檢查我的網站,它沒有顯示那個php文件中的內容。 wordpress有問題嗎?我已經完成了所有代碼,找不到任何錯誤,並且在週末沒有做任何更改。

這裏是我的PHP文件的內容的一部分:

<?php 

if ($blog_id == 1) 
    echo 
    ' 
    <script> 
    var percent = String(totalProgress.getPercent()); 
    document.write(totalProgress.toString()); 
    </script> 
    ' 
    ; 

if ($blog_id == 68) 
    echo 
    ' 
    <script> 
    var percent = String(alumniProgress.getPercent()); 
    document.write(alumniProgress.toString()); 
    </script> 
    ' 
    ; 
?> 

等..有關於這20個。他們是javascript調用。

+0

如果將include()切換到require(),會發生什麼? – andrewsi

+0

我的一切都很好,progress_chart.php正在拉動的數據?如果它在早期工作正常,我不知道腳本是否遇到了無法處理的內容,這可能會阻止它完成並輸出圖表。 – jtlowe

+0

你可能需要對'<?php include('/ wp-content/themes/your_theme_name/progress_chart.php')的影響做些什麼。 ?>'或'<?php include'/wp-content/themes/your_theme_name/progress_chart.php';沒有括號。 –

回答

2

的任這些內置的WordPress的功能應該不是一個普通的工作包括:

get_template_part ('progress_chart'); 

include locate_template('progress_chart.php'); 

http://codex.wordpress.org/Function_Reference/get_template_part http://codex.wordpress.org/Function_Reference/locate_template

編輯:使用「包括locate_template() 「如果你想讓progress_chart能夠訪問它所包含的文件中的變量。出於某種原因,get_template_part不允許這樣做。

+0

你的第二個建議工作。你有什麼想法,爲什麼我的平原包括將停止工作?我仍然難以理解原因。 – WhyAyala

+0

很高興工作。我真的不知道爲什麼你的包括停止工作。不知何故,某處肯定發生了變化,這是我能說的最多的。 – patricksayshi