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

Implement full WP_Query support #246

@westonruter

Description

@westonruter

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions