警告:require_once():http:// 包装器已禁用
Warning: require_once(): http:// wrapper is disabled
让我澄清一下。有人告诉我以下内容:
使用include_once 'http://domain.com/website/?p=154';
生成警告是因为我对包含的文件使用了完整的 URL。这不是正确的方法,因为这样我将从网络服务器获得一些 HTML。
我应该使用:
require_once('../web/page-name.php');
这样网络服务器就可以执行脚本并提供其输出,而不仅仅是提供源代码(我当前的情况导致警告)。
在 Wordpress 中创建页面时,它会提供一个短链接和一个永久链接,但不会提供实际页面-name.php(至少我不知道)。
短链接:http:// domain.com/website/?p=154
永久链接:http:// domain.com/website/index.php/listing/
所以我的问题是,有没有办法使用包含来包含或不包含上述页面。如果不是,简单地说不,而不是居高临下,因为如果我知道答案,我就不会在这个网站上发帖,对吗?
没关系,我刚刚找到了答案。我总共花了 5 个小时才弄明白这一点。我想我应该推迟在这里发布问题的时间。
答案:
<?php
$include = get_pages('include=154');
$content = apply_filters('the_content',$include[0]->post_content);
echo $content;
?>
让我澄清一下。有人告诉我以下内容:
使用include_once 'http://domain.com/website/?p=154';
生成警告是因为我对包含的文件使用了完整的 URL。这不是正确的方法,因为这样我将从网络服务器获得一些 HTML。
我应该使用:
require_once('../web/page-name.php');
这样网络服务器就可以执行脚本并提供其输出,而不仅仅是提供源代码(我当前的情况导致警告)。
在 Wordpress 中创建页面时,它会提供一个短链接和一个永久链接,但不会提供实际页面-name.php(至少我不知道)。
短链接:http:// domain.com/website/?p=154
永久链接:http:// domain.com/website/index.php/listing/
所以我的问题是,有没有办法使用包含来包含或不包含上述页面。如果不是,简单地说不,而不是居高临下,因为如果我知道答案,我就不会在这个网站上发帖,对吗?
没关系,我刚刚找到了答案。我总共花了 5 个小时才弄明白这一点。我想我应该推迟在这里发布问题的时间。
答案:
<?php
$include = get_pages('include=154');
$content = apply_filters('the_content',$include[0]->post_content);
echo $content;
?>