Echo post content by post ID

If you need to get content from a specific page or post in your template this short code will help. Simply place it in your theme file and adjust the pagepost id on top.

/**
 * Snippet Name: Echo post content by post ID
 * Snippet URL: https://www.wpcustoms.net/snippets/echo-post-content-post-id/
 */
  $my_postid = 4;//This is 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; 

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x