Prevent the same posts from showing in multiple grids/lists on a page

You can show as many Views on a page as you want. Each View will return a list of posts which match its “Filter Settings” configuration. There is a possible case that a same post appears in different Views, because it matches the Filter Settings of these Views.
In case you want to prevent same posts from showing in multiple Views on same page, please add this code to file functions.php in the theme’s folder (or install this plugin Code Snippets then add this code to the “Code” textarea):

// Content Views Pro - prevent same posts appear in multi Views on same page
$GLOBALS['cvp_shown_posts'] = array();
add_action( 'pt_cv_after_process_item', 'cvp_theme_after_process_item1' );
function cvp_theme_after_process_item1() {	
	if ( isset( $GLOBALS[ 'cv_posts' ] ) ) {
		$GLOBALS['cvp_shown_posts'] = array_merge( $GLOBALS['cvp_shown_posts'], array_keys( $GLOBALS[ 'cv_posts' ] ) );
	}
}
add_filter( 'pt_cv_post__not_in', 'cvp_theme_post__not_in1', 100, 2 );
function cvp_theme_post__not_in1( $args, $settings ) {	
	$args = array_merge( $args, $GLOBALS['cvp_shown_posts'] );
	return $args;
} // end

Best regards,

Scroll to Top