Yes, you can use template_include
or the more specific single_template
.
Example code:
add_filter( 'single_template', function( $template ) {
$cpt = [ 'america', 'nepal', 'norway' ];
return in_array( get_queried_object()->post_type, $cpt, true )
? 'path/to/country-single.php'
: $template;
} );
single_template
filter runs only for singular queries, so you don’t need to check you are on a singular view, but just check that the queried post type is one of the CPTs you want to replace the template for.
I used get_queried_object()
for the scope.