/grid/query_args
This filter is called before the grid query is ran to fetch posts, terms or users.
It allows to dynamically change the query args of WP_Query
, WP_Term_Query
or WP_User_Query
Argument | Type | Description |
$query_args | array | Holds query arguments |
$grid_id | integer | Grid id |
[pastacode lang=”php” manual=”function%20prefix_query_args(%20%24query_args%2C%20%24grid_id%20)%20%7B%0A%0A%09%2F%2F%20If%20it%20matches%20grid%20id%201%2C%20we%20exclude%20post%20IDs%201%2C2%2C3%2C4.%20%0A%09if%20(%201%20%3D%3D%3D%20%24grid_id%20)%20%7B%20%24query_args%5B’post__not_in’%5D%20%3D%20%5B%201%2C%202%2C%203%2C%204%20%5D%3B%0A%0A%09%7D%0A%0A%09return%20%24query_args%3B%0A%0A%7D%0A%0Aadd_filter(%20’wp_grid_builder%2Fgrid%2Fquery_args’%2C%20’prefix_query_args’%2C%2010%2C%202%20)%3B” message=”” highlight=”” provider=”manual”/]