Add get_post_content()/get_post_excerpt() and save_postdata()/restore_postdata() for support.
|Reported by:||mikeschinkel||Owned by:||chriscct7|
|Component:||Posts, Post Types||Keywords:||has-patch dev-feedback|
Currently the get_the_content() and get_the_excerpt() functions return the values from the loop but do not allow a Post object to be passed. These functions in the patch (get_post_content() and get_post_excerpt()) save and then restore the global variables assigned by setup_postdata() so that get_the_content() can be called for a specific post.
The functions to save and restore the postdata are save_postdata() and restore_postdata() respectively, and they simply capture the values of the global variables set in setup_postdata() into an array and then restore them back from the array.
This is the first of a broader patch I hope to supply with functions for get_post_*() and the_post_*() that would each receive as their first parameter a Post object/post ID/post array and as a second an array of $args so that robust code can be written related to posts and so that there will be a set of functions for this with a consistent set of parameters.