Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Implement full WP_Query support #246

Closed
westonruter opened this issue Sep 4, 2016 · 0 comments · Fixed by #248
Closed

Implement full WP_Query support #246

westonruter opened this issue Sep 4, 2016 · 0 comments · Fixed by #248
Milestone

Comments

@westonruter
Copy link
Contributor

Ensuring that the posts returned from a WP_Query accurately reflect the previewed post changes is a big deficiency in the plugin currently. The current logic to handle this looks at the query vars and then injects additional ID IN (…) and ID NOT IN (…) conditions to the WHERE clause. See WP_Customize_Posts_Preview::filter_posts_where_to_include_previewed_posts() which applies on the posts_where filter. That method currently has a todo:

There are undoubtedly hundreds of possible conditions that are not being accounted for in regards to all of the possible query vars a WP_Query can take.

There is also the problem of making sure that newly-created customized posts (which have an underlying auto-draft state and which have 0000-00-00 as the date) appear in the proper order (the logic in \WP_Customize_Posts_Preview::filter_the_posts_to_preview_settings() is insufficient because it is not aware of pagination).

I've been thinking that what we basically have to replicate the logic in WP_Query to augment the query results as required to accurately preview changes. Search indexes commonly intercept the query vars and add filters to get the results from another source and inject them via filtering the_posts. See https://github.com/10up/ElasticPress/blob/develop/classes/class-ep-wp-query-integration.php

In WP 4.6 there is a new option and that is the new posts_pre_query filter in 4.6. (See ticket #36687.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant