zartgesotten
12/15/2017 - 11:20 AM

Remove current Post from loop in Beaver Builder

You might want to display "related" posts via Themer and a grid or other content module. Too bad, they also display the current Post. This code goes into functions.php and removes the current post from the loop on single pages.

<?php
add_filter( 'fl_builder_loop_query_args', 'probb_exclude_current_post' );
function probb_exclude_current_post( $args )
{
  //add post type here
if( is_singular( 'referenz' ) )
{
$args['post__not_in'] = array( get_the_ID() );
}

return $args;
}
?>