Skip to main content
Home / Code Snippets / WordPress / Get Content by ID

Get Content by ID

Apparently there is no succinct WordPress function for just returning the content of a particular page by the ID of that page. This is that.

function get_the_content_by_id($post_id) {
  $page_data = get_page($post_id);
  if ($page_data) {
    return $page_data->post_content;
  else return false;
icon-link icon-logo-star icon-search icon-star