[wp-trac] [WordPress Trac] #12955: Add get_post filter
WordPress Trac
noreply at wordpress.org
Wed Aug 3 18:46:47 UTC 2016
#12955: Add get_post filter
------------------------------------+-----------------------------
Reporter: JohnLamansky | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Future Release
Component: Posts, Post Types | Version:
Severity: normal | Resolution:
Keywords: has-patch dev-feedback | Focuses:
------------------------------------+-----------------------------
Comment (by danieliser):
Replying to [comment:40 flixos90]:
> A while back I opened #34875 which overlaps with this one quite a bit.
In the description of that ticket I have another proposal of what using a
custom post object could look like - looking at that code snippet now, it
is not error-free, but I think it gives an idea of the approach (I'll
probably create an updated version this or next week). I think being able
to filter the name of the class and then create the instance based on that
name would be an alternative solution to
think about.
100% agree. The only reason I have been following this ticket and looking
for a solution was exactly that. I wanted to replace the WP_Post object
with a custom one.
Can this be done with a simple filter just before the instantiation of the
Post object?
IE
{{{#!php
<?php
$object_name = apply_filters( 'WP_Post', $post_row );
$post = new $object_name( $post_row );
}}}
That could be a super simple fix for this and allow a per item object
replacement (based on post type, status etc).
I haven't read all the responses here but that 100% would solve my & a lot
of others needs with a simple non breaking change.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/12955#comment:41>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list