Get post content from outside the loop

You can use get_page() to return the $post object of a static page:

$page_id = 302;
$page_object = get_page( $page_id );
echo $page_object->post_content;

Edit

Similarly, you can use get_post() to return the $post object of a post:

$post_id = 302;
$post_object = get_post( $post_id );
echo $post_object->post_content;

Leave a Comment