[英]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.