仍然需要帮助。。。将Wordpress页面内容嵌入PHP站点

仍然需要帮助。。。将Wordpress页面内容嵌入PHP站点,php,wordpress,Php,Wordpress,我在网上和这里做了很多搜索,但都找不到答案,尽管我知道这可能非常简单。我错过了一些东西 我正在尝试将Wordpress页面(由Wordpress插件All-In-one Event Calendar自动创建的页面)的内容嵌入到我网站的页面中 (注意:我已经确认“页面”和“帖子”是同一件事……) 当我访问Wordpress codex时,我得到了这个页面:它告诉我get_page函数已被弃用,并将我发送到codex的“get post”页面 我试图嵌入的wordpress页面(不是帖子)的URL看

我在网上和这里做了很多搜索,但都找不到答案,尽管我知道这可能非常简单。我错过了一些东西

我正在尝试将Wordpress页面(由Wordpress插件All-In-one Event Calendar自动创建的页面)的内容嵌入到我网站的页面中

(注意:我已经确认“页面”和“帖子”是同一件事……)

当我访问Wordpress codex时,我得到了这个页面:它告诉我get_page函数已被弃用,并将我发送到codex的“get post”页面

我试图嵌入的wordpress页面(不是帖子)的URL看起来像

我的网站顶部有以下代码

<?php 
/* Short and sweet */
define('WP_USE_THEMES', false);
require('/home3/xxxxxx/public_html/xxxxxx/xxxxxx/blog/wp-load.php');
?>

(注意:我们已经确认wp-load可以工作……wp-blog-header.php不能。谢谢,培根!)

并创建了循环:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); 
 $id = 4;
 $p = get_post($id);
 echo apply_filters('the_content', $p->post_content);
 endwhile; else : 
_e( 'Sorry, no posts matched your criteria.' ); 
endif; ?>

我尝试嵌入页面内容时使用的代码是:

<?php
 $id = 4;
 $p = get_post($id);
 echo apply_filters('the_content', $p->post_content);
 ?>

它似乎不起作用。它返回错误消息(抱歉,没有与您的条件匹配的帖子。)但是有一个ID为4的帖子(页面)

我错过了什么


请温和一点,并提前感谢您提供的任何帮助。

需要wp-load.php而不是wp-blog-header.php


get_post($id)也可以作为获取页面的一种方式

谢谢你的回复。我试过了,但还是不起作用。还有其他想法吗?:)也许是一个Iframe?hahaStill需要帮助,如果有人能提供。。。谢谢