通过 ID 获取内容

Avatar of Chris Coyier
Chris Coyier

显然,没有简洁的 WordPress 函数可以只通过页面 ID 返回特定页面的内容。这就是那个函数。

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;
}