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:
$resultsis the results array (empty by default). The loop will iterate through this array.$query_objis an instance of the\Bricks\Queryclass 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:
- Posts:
bricks/posts/query_vars - Terms: bricks/terms/query_vars
- Users: bricks/users/query_vars
Related hooks:
- To add a query type to the Query control use
bricks/setup/control_options - To manage the object on every loop iteration use
bricks/query/loop_object
Was this helpful?
A quick vote and short notes help us improve these docs faster.
Leave a note for us
Please do not include passwords, license keys, or personal data. We store submitted notes to improve the docs.
Thanks for sharing feedback. We're using it to improve these docs.