get_postdata

Retrieves all post data for a given post.

Description

(array) get_postdata( (int) $postid ); 

Returns (array)

Post data.

Parameters (1)

0. $postid (int)
The postid.

Usage

  1. if ( !function_exists( 'get_postdata' ) ) { 
  2. require_once ABSPATH . WPINC . '/deprecated.php'; 
  3.  
  4. // The postid. 
  5. $postid = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_postdata($postid); 
  9.  

Defined (1)

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

/wp-includes/deprecated.php  
  1. function get_postdata($postid) { 
  2. _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' ); 
  3.  
  4. $post = get_post($postid); 
  5.  
  6. $postdata = array ( 
  7. 'ID' => $post->ID,  
  8. 'Author_ID' => $post->post_author,  
  9. 'Date' => $post->post_date,  
  10. 'Content' => $post->post_content,  
  11. 'Excerpt' => $post->post_excerpt,  
  12. 'Title' => $post->post_title,  
  13. 'Category' => $post->post_category,  
  14. 'post_status' => $post->post_status,  
  15. 'comment_status' => $post->comment_status,  
  16. 'ping_status' => $post->ping_status,  
  17. 'post_password' => $post->post_password,  
  18. 'to_ping' => $post->to_ping,  
  19. 'pinged' => $post->pinged,  
  20. 'post_type' => $post->post_type,  
  21. 'post_name' => $post->post_name 
  22. ); 
  23.  
  24. return $postdata;