Make WordPress Core

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's profile 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.

Attachments (1)

37316.diff (499 bytes) - added by jason_the_adams 9 years ago.

Download all attachments as: .zip

Change History (3)

#1 @jason_the_adams
9 years ago

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 use WP_Post::get_instance), but I'm starting with a proof-of-concept.

#2 @ocean90Core Committer
9 years ago

  • Component changed from Query to Posts, Post Types
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version trunk deleted

Duplicate of #30292 and #12955.

Note: See TracTickets for help on using tickets.