Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Talk:Function Reference/setup postdata

Interaction with $post global

I was confused by this text in the description:

It does not assign the global $post variable, but seems to expect that its argument is a reference to it. 

Looking at the code, I don't see any reference to the $post global in setup_postdata, and at a glance none of the functions it calls seem to care about it either. As far as I can tell this is not accurate.

However *other* WP internals appear to use global $post in addition to the globals setup by setup_postdata, so the end result is the same - if you `setup_postdata($new_post)`, you should also set `$GLOBALS['post'] = $new_post`. I'm clarifying the language a bit based on this understanding, please revert if I'm getting it wrong.

Mslade (talk)

Improvement Needed

From this article, I can see where it's used, but I still can't tell why it's used or what the point is of including/excluding it. Could someone please answer the simple question: what's the point of this function? Jwk 01:58, 18 November 2012 (UTC)