Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#37316 closed enhancement (duplicate)

Allow WP_Post to be filtered at instantiation

Reported by: jason_the_adams Owned by:
Priority: normal Milestone:
Component: Posts, Post Types Version:
Severity: normal Keywords:
Cc: Focuses:

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 10 years ago.

Download all attachments as: .zip

Change History (3)

#1 @jason_the_adams
10 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 @ocean90
10 years ago

  • Component Query → Posts, Post Types
  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed
  • Version trunk

Duplicate of #30292 and #12955.

Note: See TracTickets for help on using tickets.