setup_postdata

Set up global post data.

Description

setup_postdata( (WP_Post|object|int) $post ); 

Parameters (1)

0. $post (WP_Post|object|int)
WP_Post instance or Post ID/object.

Usage

  1. if ( !function_exists( 'setup_postdata' ) ) { 
  2. require_once ABSPATH . WPINC . '/query.php'; 
  3.  
  4. // WP_Post instance or Post ID/object. 
  5. $post = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = setup_postdata($post); 
  9.  

Defined (1)

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

/wp-includes/query.php  
  1. function setup_postdata( $post ) { 
  2. global $wp_query; 
  3.  
  4. if ( ! empty( $wp_query ) && $wp_query instanceof WP_Query ) { 
  5. return $wp_query->setup_postdata( $post ); 
  6.  
  7. return false;