Opened 6 years ago
Closed 6 years ago
#42924 closed defect (bug) (invalid)
Current implementation of WP_Post::get_instance makes the_posts and posts_results filters useless
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.1 |
Component: | Query | Keywords: | |
Focuses: | Cc: |
Description
The only possible idea of the_posts and posts_results filters is to allow post data modifications just after posts are fetched from database. But it is useless if there are other ways to load posts without filtering. Since WP_Post::get_instance does not pass its data through these filters (or any other) it makes them useless. This may be seen for example on bbPress topic page, where last reply is fetched separately (for any reason, I did not make an investigation why its done this way).
Change History (1)
Note: See
TracTickets for help on using
tickets.
Hi @panbolec and welcome to Trac.
These filters are designed to be used to provide
WP_Query
results directly from another data-source, such as from a cache (memcache) or from another query engine (elastic search, sphinx, etc). The two hooks mentioned by themselves are not solely responsible for that, and are AFAIK mostly the post-query save-in-cache variants.They're not designed to be used for "post data modifications", although you could attempt it (you'd also have to use a much later hook in conjunction with it I believe).
It seems that you may be asking for a filter to allow
WP_Post
objects to be modified after querying, if that's the case, I'll redirect that to #12955