Support

Account

Home Forums Feedback Documentation for Post Object

Helping

Documentation for Post Object

  • It may be that the documentation for Post Object needs a small but helpful improvement in the code example for “Display data for a single post object”:

    if( $post_object ): 
    
    	// override $post
    	global $post;// this is missing I think
    	$post = $post_object;
    	setup_postdata( $post );

    At least in my hopeless fumblings, this would have saved me a quite a bit of time finding the difference to the codex.

  • I think the documentation assumes that the code is in a standard WP template file (or even in a file loaded with get_template_part()) where the $post variable is already set up for you.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Documentation for Post Object’ is closed to new replies.