/facet/query_string
This filter is called before the content is queried from WP_Query
, WP_Term_Query
or WP_User_Query
It allows to filter content by adding facet slug/values in the query string. This filter is pretty useful to prefilter content on load.
Argument | Type | Description |
$query_string | array | Holds query strings parameters |
$grid_id | mixed | Grid ID or template ID/name |
$action | string | Current action type (render or refresh) |
[pastacode lang=”php” manual=”function%20prefix_filter_query(%20%24query_string%2C%20%24grid_id%2C%20%24action%20)%20%7B%0A%0A%09%09%2F%2F%20If%20the%20content%20is%20not%20filtered%20on%20first%20render.%20%0A%09%09if%20(%20’render’%20%3D%3D%3D%20%24action%20%26%26%20empty(%20%24query_string%20)%20)%20%7B%20%0A%09%09%09%24query_string%20%3D%20%5B%0A%09%09%09%09’rating_facet_slug’%20%3D%3E%20%5B%20’4’%20%5D%2C%0A%09%09%09%09’price_facet_slug’%20%3D%3E%20%5B%20’35’%2C%20’150’%20%5D%2C%20%0A%09%09%09%09’category_facet_slug’%20%3D%3E%20%5B%20’clothing’%2C%20’hoodies’%20%5D%20%0A%09%09%5D%3B%0A%0A%09%7D%0A%0A%09return%20%24query_string%3B%0A%0A%7D%0A%0Aadd_filter(%20’wp_grid_builder%2Ffacet%2Fquery_string’%2C%20’prefix_filter_query’%2C%2010%2C%203%20)%3B” message=”” highlight=”” provider=”manual”/]