Rather than call WP_Query()
you can use get_post()
and “set up” the global $post
. This is probably a little more efficient than @tf’s answer, though the ideas are broadly the same.
Please note, in both cases you should reset the post data afterwards.
/**
* Display the post content. Optionally allows post ID to be passed
* @uses the_content()
*
* @param int $id Optional. Post ID.
* @param string $more_link_text Optional. Content for when there is more text.
* @param bool $stripteaser Optional. Strip teaser content before the more text. Default is false.
*/
function sh_the_content_by_id( $post_id=0, $more_link_text = null, $stripteaser = false ){
global $post;
$post = &get_post($post_id);
setup_postdata( $post, $more_link_text, $stripteaser );
the_content();
wp_reset_postdata();
}