How to output only the post content

Assuming you are in the loop, or otherwise know (or know how to get) the $post object:

function wpse63358_get_post_content() {
    global $post;
    return $post->post_content;
}

If you want the formatted post content, replace this:

return $post->post_content;

…with this:

return apply_filters( 'the_content', $post->post_content );

To echo the function output:

echo wpse63358_get_post_content();

Edit

Note: if you just want to output post content in the template, you don’t actually even have to bother with wrapping it in a function. Simply use:

global $post;
echo apply_filters( 'the_content', $post->post_content );

Leave a Comment