Get Bricks

Filter: bricks/posts/query_vars

Since Bricks 1.3.2 you may manipulate the posts, products, or Query Loop elements query vars before the query is performed like so:

add_filter( 'bricks/posts/query_vars', function( $query_vars, $settings, $element_id ) {
    // Use an ACF custom field to restrict the query to a set of posts
    if ( $element_id == 'fhmnfx' && function_exists('get_field') ) {
        $query_vars['post__in'] = get_field('my_posts_acf_field');
    }

    return $query_vars;
}, 10, 3 );

The filter callback receives three arguments:

  • $query_vars an associative array used to feed the WP_Query class
  • $settings an associative array containing the element settings set in the builder
  • $element_id is a string containing the unique element ID (since Bricks 1.3.6)