[wp-trac] [WordPress Trac] #14958: Add a "get_post" filter to get_post()

WordPress Trac noreply at wordpress.org
Thu Aug 8 14:29:30 UTC 2013


#14958: Add a "get_post" filter to get_post()
-----------------------------+-----------------------------
 Reporter:  mikeschinkel     |       Owner:
     Type:  enhancement      |      Status:  new
 Priority:  normal           |   Milestone:  Future Release
Component:  Query            |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  has-patch close  |
-----------------------------+-----------------------------

Comment (by MikeSchinkel):

 Replying to [comment:8 wonderboymusic]:
 > `get_post()` returns a `WP_Post` instance - you can decorate that.
 >
 > {{{
 > $post = get_post( $id );
 > $post->extra = 'sauce';
 > }}}

 Unfortunately that solution does not address the use-case for which I
 posted this ticket.  Further, it being a `WP_Post` isn't relevant to the
 proposed solution because you could have done exactly the same before when
 it was an stdClass object.

 The goal of the ticket was to gain the ability to ensure that all posts
 that were retrieved for a selected post type had been decorated with other
 items, i.e. custom fields, child posts, etc. It could also be a method for
 instrumentation or anything else you'd want to do to ensure that all posts
 objects created WordPress' code, by other plugin's code or by themes have
 the properties desired.

 However, since the 3 years that have passed as this ticket languished the
 inclusion of `WP_Post` actually provides a better location for the hook to
 address the desired use-case, i.e. **in the constructor of `WP_Post`**.
 Given that it does makes sense to close this ticket but not for the
 reasons you mentioned but because a new ticket is more relevant; an
 `'instantiated_post'` hook.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/14958#comment:9>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list