get_page

Retrieves page data given a page ID or page object.

Description

(WP_Post|array|null) get_page( (mixed) $page, (constant) $output = OBJECT, (string) $filter = 'raw' ); 

Use get_post() instead of get_page().

Returns (WP_Post|array|null)

WP_Post (or array) on success, or null on failure.

Parameters (3)

0. $page (mixed)
Page object or page ID. Passed by reference.
1. $output — Optional. (constant) => OBJECT
The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a WP_Post object, an associative array, or a numeric array, respectively. Default OBJECT.
2. $filter — Optional. (string) => 'raw'
How the return value should be filtered. Accepts raw,, edit., db, display. Default raw,.

Usage

  1. if ( !function_exists( 'get_page' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3.  
  4. // Page object or page ID. Passed by reference. 
  5. $page = null; 
  6.  
  7. // Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to 
  8. // a WP_Post object, an associative array, or a numeric array, respectively. Default OBJECT. 
  9. $output = OBJECT; 
  10.  
  11. // Optional. How the return value should be filtered. Accepts 'raw', 
  12. // 'edit', 'db', 'display'. Default 'raw'. 
  13. $filter = 'raw'; 
  14.  
  15. // NOTICE! Understand what this does before running. 
  16. $result = get_page($page, $output, $filter); 
  17.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post.php  
  1. function get_page( $page, $output = OBJECT, $filter = 'raw') { 
  2. return get_post( $page, $output, $filter );