Get Bricks

Filter: bricks/query/run

The Bricks Query Loop supports 3 types of queries by default (Posts, Terms and Users). But it can be extended to support any other query. To return a custom query result, Bricks can be extended using the WP filter bricks/query/run like so:

add_filter( 'bricks/query/run', function( $results, $query_obj ) {
    if ( $query_obj->object_type !== 'my_query_type' ) {
	return $results;

    // Perform the query
    // Assign the results to $results (array)
    return $results;
}, 10, 2 );

The filter callback receives two arguments:

  • $results is the results array (empty by default). The loop will iterate through this array.
  • $query_obj is an instance of the \Bricks\Query class object

Note: This hook should be used to add different types of query results. If you want to alter the posts, terms, or users query, use the following hooks:

Related hooks: