0

When i need to get content of a post with ID, I'm always using this function :

function getContentByID($id)
{
//http://wordpress.stackexchange.com/questions/9667/get-wordpress-post-content-by-post-id
$content_post = get_post($id);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}

Can you tell me, why there isn't any core function for this ? There are functions like get_the_title($id), get_the_category($id) ...

Eray
  • 445
  • 2
  • 5
  • 19

1 Answers1

2

There is get_post_field(), which is very, very close to your proposed solution.

$content = get_post_field('post_content',$your_post_id);

Frankly, I think WordPress already suffers from helper function overload, but there you go.

s_ha_dum
  • 65,658
  • 13
  • 84
  • 174