/indexer/query_args
This filter is called before WP_Query
, WP_Term_Query
or WP_User_Query
is ran from the indexer.
It allows to modifies query arguments of the current facet to index. When a facet is indexed, the indexer retrieves at first all post/term/user IDs matching the facet. This filter allows to modify which object ids to retrieve.
Argument | Type | Description |
$query_args | array | Holds indexer query args |
$object_type | string | Current object type to index (post, term or user) |
$facet | array | Holds facet settings |
[pastacode lang=”php” manual=”function%20prefix_indexer_query_args(%20%24query_args%2C%20%24object_type%2C%20%24facet%20)%20%7B%0A%09%09%0A%09%2F%2F%20We%20exclude%20post%20IDs%20from%20indexer%20for%20Facet%20ID%20is%20equal%20to%201.%0A%09if%20(%201%20%3D%3D%3D%20%24facet%5B’id’%5D%20)%20%7B%0A%09%09%24query_args%5B’post__not_in’%5D%20%3D%20%5B%201%2C%202%2C%203%2C%204%20%5D%3B%20%0A%09%7D%20%0A%0A%09%2F%2F%20We%20only%20index%20published%20posts%20(by%20default%20it%20indexes%20any%20post%20status).%0A%09if%20(%20’post’%20%3D%3D%3D%20%24object_type%20)%20%7B%0A%09%09%24query_args%5B’post_status’%5D%20%3D%20’publish’%3B%0A%09%7D%20%0A%0A%09return%20%24query_args%3B%0A%7D%0A%0Aadd_filter(%20’wp_grid_builder%2Findexer%2Fquery_args’%2C%20’prefix_indexer_query_args’%2C%2010%2C%203%20)%3B” message=”” highlight=”” provider=”manual”/]