Reputation: 21
've done a lot of searching on the net and here, and cannot find the answer to this, though I know it may be ridiculously simple. I'm missing something...
I am trying to embed the content of a Wordpress PAGE (one which was created automatically by the Wordpress plugin All In One Event Calendar) into a page on my website.
(Note: I've confirmed that "page" and "post" are the same thing...)
When I visited the Wordpress codex, I got this page: http://codex.wordpress.org/Function_Reference/get_page which tells me that the get_page function has been deprecated and send me to the "get post" page of the codex.
The URL of the wordpress PAGE (not POST) that I'm trying to embed looks like http://xxxxxx.com/test/blog/?page_id=4.
I have the following code at the top of my site...
<?php
/* Short and sweet */
define('WP_USE_THEMES', false);
require('/home3/xxxxxx/public_html/xxxxxx/xxxxxx/blog/wp-load.php');
?>
(Note: have confirmed that wp-load works... wp-blog-header.php DOES NOT. Thanks, Bacon!)
And created the loop:
<?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; ?>
The code I am using to attempt to embed the page content is:
<?php
$id = 4;
$p = get_post($id);
echo apply_filters('the_content', $p->post_content);
?>
It doesn't seem to be working. It returns the error message (Sorry, no posts matched your criteria.) Yet there IS a post (page) with the ID of 4.
What am I missing?
Please be gentle and thank you in advance for any help you can provide.
Upvotes: 0
Views: 151
Reputation: 4861
Require wp-load.php instead of wp-blog-header.php.
get_post($id) should also work as a way to get a page.
Upvotes: 0