Get all the posts for a CPT archive
// pre_get_posts to get all the posts por the CPT Archive
add_action( 'pre_get_posts', 'pre_get_posts_archive_custom_cpt' );
function pre_get_posts_archive_custom_cpt( $query ) {
if( is_admin() ) {
return;
}
if ( $query->is_post_type_archive( 'custom_cpt_name' ) && $query->is_main_query() ) {
$query->set( 'posts_per_page', -1 );
}
}