[wp-hackers] Format post content outside of loop

David House dmhouse at gmail.com
Thu Apr 20 17:07:36 GMT 2006

On 20/04/06, Paul Menard <codehooligans at codehooligans.com> wrote:
> So dumb question I'm sure. I need to grab the post_content variable
> to include in an HTML email. Normally I call $post->the_content()
> which will echo the formatted content to the screen.

Actually, you never call $post->the_content(), the_content() is a
global function (not a method) which echoes $post->post_content.

If the post you want to email is one of the ones selected (i.e., it's
in $posts), then use apply_filters('the_content', $posts[n]); If it's
not, use:

$post_to_email = get_post(ID);
$content = apply_filters('the_content', $post_to_email->post_content);

-David House, dmhouse at gmail.com, http://xmouse.ithium.net

More information about the wp-hackers mailing list