Add get_post_content()/get_post_excerpt() and save_postdata()/restore_postdata() for support.
|Reported by:||mikeschinkel||Owned by:|
|Component:||Posts, Post Types||Keywords:||needs-unit-tests needs-patch|
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.
Change History (17)
20 months ago
- Milestone changed from Future Release to 4.4
- Owner set to chriscct7
- Status changed from new to reviewing
- Keywords needs-unit-tests needs-patch added; has-patch dev-feedback removed