Filtering out Media Items from “Select post/page” Bricks control

The dropdown that appears after choosing “Internal post/page” when setting a link in Bricks shows media (attachment) items besides Pages, Posts and other CPTs.

If you want to remove the Media attachment items from appearing in this list, an undocumented filter called bricks/helpers/get_posts_args can be used.

Add the following in child theme‘s functions.php or a code snippets plugin:

add_filter( 'bricks/helpers/get_posts_args', function ( $args ) {
	$post_types = get_post_types( [ 'exclude_from_search' => false ] );

	// exclude attachment
	unset( $post_types['attachment'] );

	$args['post_type'] = $post_types;

	return $args;
});

Tested in Bricks 1.9.1.1.