wp_get_single_post

Retrieve a single post, based on post ID.

Description

(WP_Post|null) wp_get_single_post( (int) $postid = 0, (string) $mode = ); 

Has categories in post_category property or key. Has tags in tags_input property or key.

Returns (WP_Post|null)

Post object or array holding post contents and information

Parameters (2)

0. $postid — Optional. (int)
The postid.
1. $mode (string)
How to return result, either OBJECT, ARRAY_N, or ARRAY_A.

Usage

  1. if ( !function_exists( 'wp_get_single_post' ) ) { 
  2. require_once ABSPATH . WPINC . '/deprecated.php'; 
  3.  
  4. // The postid. 
  5. $postid = -1; 
  6.  
  7. // How to return result, either OBJECT, ARRAY_N, or ARRAY_A. 
  8. $mode = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_get_single_post($postid, $mode); 
  12.  

Defined (1)

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

/wp-includes/deprecated.php  
  1. function wp_get_single_post( $postid = 0, $mode = OBJECT ) { 
  2. _deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' ); 
  3. return get_post( $postid, $mode );