[wp-trac] [WordPress Trac] #30970: setup_postdata should be able to accept a Post ID, currently requires full WP Post object

WordPress Trac noreply at wordpress.org
Sat Jan 10 14:27:15 UTC 2015


#30970: setup_postdata should be able to accept a Post ID, currently requires full
WP Post object
------------------------------------------+------------------------------
 Reporter:  sc0ttkclark                   |       Owner:
     Type:  enhancement                   |      Status:  new
 Priority:  normal                        |   Milestone:  Awaiting Review
Component:  Posts, Post Types             |     Version:  1.5
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:
------------------------------------------+------------------------------
Changes (by boonebgorges):

 * keywords:   => needs-patch needs-unit-tests


Comment:

 This seems reasonable. We should be able to simplify your suggested logic
 a bit: `if ( ! ( $post instanceof WP_Post ) ) { $post = get_post( $post );
 }` will cover either an int or a faux-WP_Post object.

 I'd like to see some unit tests for the various scenarios you've laid out
 (int, faux post, WP_Post; `$post` global populated vs not populated).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30970#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list