Get post content by ID

You can do it multiple ways. Following are best two ways.

$post_id = 5// example post id
$post_content = get_post($post_id);
$content = $post_content->post_content;
echo do_shortcode( $content );//executing shortcodes

Another method

$content = get_post_field('post_content', $post_id);
echo do_shortcode( $content );//executing shortcodes

After Pieter Goosen suggestion on apply_filters.

You can use apply_filters if you wanted the content to be filtered by other plugins. So this eliminates the need to use do_shortcode

Example

$post_id = 5// example post id
$post_content = get_post($post_id);
$content = $post_content->post_content;
echo apply_filters('the_content',$content);
 //no need to use do_shortcode, but content might be filtered by other plugins.

If you don’t want to allow other plugins to filter this content and need shortcode function then go with do_shortcode.

If you don’t want shortcode too then just play with the post_content.

Leave a Comment