[wp-trac] [WordPress Trac] #12955: Add get_post filter

WordPress Trac noreply at wordpress.org
Fri Mar 23 05:15:44 UTC 2018


#12955: Add get_post filter
------------------------------------------------+--------------------------
 Reporter:  JohnLamansky                        |       Owner:
     Type:  feature request                     |      Status:  new
 Priority:  normal                              |   Milestone:  Future
Component:  Posts, Post Types                   |  Release
 Severity:  normal                              |     Version:
 Keywords:  has-patch dev-feedback 2nd-opinion  |  Resolution:
                                                |     Focuses:
------------------------------------------------+--------------------------

Comment (by danieliser):

 @Mte90 What are you looking for in terms of examples? How a get_post
 object filter would look? Or how it looks now without it, or what it would
 look like with final removed and an extendable model.

 Keep in mind if you remove final and we can extend WP_Post, that is only
 half the issue. This ticket is still 100% relevant as you are gonna still
 need to manually loop over $query->posts and replace WP_Post objects with
 your new Custom_Post object.

 All of which can be avoided if there is a way to modify which class is
 used to instantiate the object returned.

 So if you had both tickets merged we could easily define a custom class
 extending WP_Post, then call built in WP methods such as get_posts, new
 WP_Query() etc and return a ready to use loop of our Custom_Post objects.

 Just a simplification for the growing needs of custom data object
 structures wrapped around the custom post type systems.

 I have examples of nearly all of these in one plugin, though we copied and
 prefixed WP_Post without final. IE we use custom objects, have query
 wrappers to replace WP_Post etc. Takes up a lot of code ;).

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


More information about the wp-trac mailing list