【函数用法】

<?php get_page( $page_id ) ?>

【函数参数】

(object|array)
mixed Page data.
   [ID]                    => (integer)
   [post_author]           => (integer)
   [post_date]             => (YYYY-MM-DD HH:MM:SS)
   [post_date_gmt]         => (YYYY-MM-DD HH:MM:SS)
   [post_content]          => (all post content is in here)
   [post_title]            => (Post Title Here)
   [post_excerpt]          => (Post Excerpt)
   [post_status]           => (? | publish)
   [comment_status]        => (? | closed)
   [ping_status]           => (? | closed)
   [post_password]         => (blank if not specified)
   [post_name]             => (slug-is-here)
   [to_ping]               => (?)
   [pinged]                => (?)
   [post_modified]         => (YYYY-MM-DD HH:MM:SS)
   [post_modified_gmt]     => (YYYY-MM-DD HH:MM:SS)
   [post_content_filtered] => (?)
   [post_parent]           => (integer)
   [guid]                  => (a unique identifier that is not necessarily the URL to the Page)
   [menu_order]            => (integer)
   [post_type]             => (? | page)
   [post_mime_type]        => ()?)
   [comment_count]         => (integer)
   [ancestors]             => (object|array)
   [filter]                => (? | raw)

如果你要获取页面的URL,不要使用guid字段值。使用the_permalink或者get_permalink 代替。
如果页面不存在,返回null

【函数示例】

<?php
$page_id = 123;

$page_data = get_page( $page_id );
//必须传递个变量. 如果传递值 (e.g. get_page ( 123 ); ), WordPress会报错. 默认将会返回一个对象.

echo '<h3>'. $page_data->post_title .'</h3>';// 输出标题

echo apply_filters('the_content', $page_data->post_content); //输出内容
?>

【源代码】

get_page() 位于wp-includes/post.php.

/**
 * Retrieves page data given a page ID or page object.
 *
 * @since 1.5.1
 *
 * @param mixed $page Page object or page ID. Passed by reference.
 * @param string $output What to output. OBJECT, ARRAY_A, or ARRAY_N.
 * @param string $filter How the return value should be filtered.
 * @return mixed Page data.
 */
function &get_page(&$page, $output = OBJECT, $filter = 'raw') {
 $p = get_post($page, $output, $filter);
 return $p;
}