/grid/query_args

DescriptionDescription

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.

ArgumentsArguments

ArgumentTypeDescription
$query_args arrayHolds query arguments
$grid_idintegerGrid id

ExampleExample

PHP
functions.php
function prefix_query_args( $query_args, $grid_id ) {

	// If it matches grid id 1, we exclude post IDs 1,2,3,4.
	if ( 1 === $grid_id ) {
		$query_args['post__not_in'] = [ 1, 2, 3, 4 ];
	}

	return $query_args;

}

add_filter( 'wp_grid_builder/grid/query_args', 'prefix_query_args', 10, 2 );