Beaver Builder Post Modules: Leave Out the Current Post
Removes the post being viewed from Beaver Builder Posts, Post Slider and Post Carousel modules, so "latest posts" blocks on articles never repeat the article itself.
Opens WPIDE on
Code
add_filter( 'fl_builder_loop_query_args', function ( $args ) {
if ( ! is_singular() ) {
return $args;
}
$exclude = isset( $args['post__not_in'] ) ? (array) $args['post__not_in'] : array();
$exclude[] = get_queried_object_id();
$args['post__not_in'] = array_values( array_filter( array_map( 'absint', $exclude ) ) );
return $args;
} );
Notes
Applies to every Beaver Builder post module on single posts and pages.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.