same archive template for different custom post

There are template filters for all types of queries. You could use archive_template in this case.

function wpd210689_template_filter( $archive_template ) {
    $post_types = array( 'america', 'china', 'nepal', 'norway', 'chile' );
    if ( is_post_type_archive ( $post_types ) ) {
        $archive_template = locate_template( 'archive-country.php' );
    }
    return $archive_template;
}
add_filter( 'archive_template', 'wpd210689_template_filter' ) ;

Leave a Comment