For Single Post Template
If you are making the related terms list on a single post page template and want to exclude the current post terms from the list, you will use this filter. Write the following snippets in your child theme’s functions.php file or any 3rd party plugin.
add_filter( 'bricks/terms/query_vars', 'bu_do_terms_filter', 12, 3 ); function bu_do_terms_filter( $query_vars, $settings, $element_id ) { //* single post template if( $element_id == 'fkbhig' ) { $query_vars['exclude'] = wp_get_post_terms( get_the_ID(), 'category', array( 'fields' => 'ids' ) ); } return $query_vars; }
Bricks have a filter to edit the default query vars. In the above code, You will change the element ID “fkbhig” with your terms query loop’s element ID.
Getting the current post’s terms with wp_get_post_terms function. It is returning the terms ID in array format.
For Term Archive Page
If you made a term archive page and want to exclude the current term from the terms query loop builder, you will use this snippet.
add_filter( 'bricks/terms/query_vars', 'bu_do_terms_filter', 12, 3 ); function bu_do_terms_filter( $query_vars, $settings, $element_id ) { if( $element_id == 'pilbnn' ) { $query_vars['exclude'] = [ get_queried_object()->term_id ]; } return $query_vars; }
Replace the element ID “pilbnn” with your element ID. Getting the current term ID with the get_queried_object() function. It is returning the OBJECT.