How To Get WordPress Content By Post ID

How to get WordPress post content by given id

You can use following way to get post content

$my_postid = 1;//page id or post id
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;

or using short way

echo apply_filters('the_content', get_post_field('post_content', $post_id));
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments