Wordpress - How to get only posts, pages and custom post types in WordPress
You can make an array of the post types you don't want and then check in_array()
to see if they match before you output anything with them.
<?php
//You'll want to get at the actual name for My Templates.
//My attempt is just a guess.
$types_array = array( 'attachment' , 'elementor_library' );
$types = get_post_types( ['public' => true ], 'objects' );
foreach ( $types as $type ) {
if( !in_array( $type->name, $types_array )) {
if ( isset( $type->labels->name) ) {
echo $type->labels->name . '<br>';
}
}
}
?>