[英]Including PHP file in Wordpress Template
截至目前,我在Wordpress主題的模板之一中已包含此代碼。
// blah blah
<div class="content">
<?php include_once( 'http://www.website.com/new/file.php?variable=1' ); ?>
</div>
// blah blah
現在,它將加載此模板中的所有內容,但此php include除外! 它將加載/ *等等* /上方的側邊欄,並將加載頁腳,導航等。
當我在Google Chrome瀏覽器中檢查Element時,它顯示如下:
<div class="content">
(it's empty)
</div>
如果您知道我在做什么錯,請幫助我! 謝謝!
include
並require
不要使用網址。 他們采用服務器文件路徑。 嘗試這個:
<?php include_once(ABSPATH.'/new/file.php'); ?>
編輯:忘記提及查詢字符串不能包含在文件路徑中。 如果需要正確輸入查詢字符串,請考慮使用當前URL中的所有必需查詢變量來加載頁面,使用iframe或使用file_get_contents()
加載部分
iframe:
<iframe src="http://www.website.com/new/file.php?variable=1"></iframe>
file_get_contents()
<?php echo file_get_contents('http://www.website.com/new/file.php?variable=1'); ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.