{"id":2132,"date":"2021-12-29T09:17:32","date_gmt":"2021-12-29T09:17:32","guid":{"rendered":"https:\/\/academy.bricksbuilder.io\/?post_type=bricks_article&p=2132"},"modified":"2023-02-14T06:27:09","modified_gmt":"2023-02-14T06:27:09","slug":"filter-bricks-posts-merge_query","status":"publish","type":"bricks_article","link":"https:\/\/academy.bricksbuilder.io\/article\/filter-bricks-posts-merge_query\/","title":{"rendered":"Filter: bricks\/posts\/merge_query"},"content":{"rendered":"\n
Since Bricks 1.3.7 you’ll be able to decide if a certain element query should be merged with the WordPress main query, in the archive or search templates, using the following filter:<\/p>\n\n\n\n
add_filter( 'bricks\/posts\/merge_query', function( $merge, $element_id ) {\n if ( $element_id === 'wghgco' ) {\n return false;\n }\n\n return $merge;\n}, 10, 2 );<\/code><\/pre>\n\n\n\nThe filter callback receives two arguments: <\/p>\n\n\n\n
\n$merge<\/code> is a boolean variable indicating whether the query should be merged or not (default: true)<\/li>\n\n\n\n$element_id<\/code> is a string containing the element ID<\/li>\n<\/ul>\n\n\n\nThis is triggered for all the Bricks elements containing one internal WP_Query query like the Posts and the Carousel element, or any other element where the Query Loop is enabled (Container, Slider, Accordion).<\/p>\n\n\n\n
<\/p>\n\n\n\n
Starting from Bricks 1.7, you can achieve the same result by utilizing the “Disable Query Merge” option in the Query Loop<\/a>, without the need for a PHP filter. Use this filter for more advanced situations.<\/p>\n\n\n\nHow to find the element ID?<\/h2>\n\n\n\n
Each element in Bricks has a unique ID. You may find the element ID when editing the element and looking into the Global CSS classes input. By default, it shows the element HTML ID (e.g. #bricks-element-wghgco<\/code>). For the purpose of this filter, we only need the last portion of the string, the six-character long element ID (e.g. wghgco<\/code>).<\/p>\n\n\n\n