Opened 9 years ago
Closed 9 years ago
#37316 closed enhancement (duplicate)
Allow WP_Post to be filtered at instantiation
Reported by: | jason_the_adams | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
Description ¶
Currently it's possible to filter the results of wp_query->get_posts
using either the 'posts_results' or 'the_posts' filters. There's no way to filter the results of the get_post
function, however.
Providing a filter for when a WP_Post is instantiated would allow themes/plugins with custom post types to add properties and such when the post(s) are retrieved. Currently wrapper functions such as get_event_post have to be made. It would be great if the standard WordPress functions could be used and CPT results reliably structured.
Pull Requests
- Loading…
Note: See
TracTickets for help on using
tickets.
Obviously this will need a test as well, and I'm still debating where the best place to put the filter is (as
get_post
doesn't always useWP_Post::get_instance
), but I'm starting with a proof-of-concept.