If anyone’s interested, the solution was quite close, I only had to specify the rewrite rule with &post_type=film :
add_rewrite_rule(
'projections_dvd/([^/]+)/?$',
'index.php?name=$matches[1]&post_type=film&is_projections_dvd=1',
'top'
);
I also changed the query vars to make it simpler :
function wpd_query_var( $query_vars ) {
$query_vars[] = 'is_international';
$query_vars[] = 'is_france';
$query_vars[] = 'is_projections_dvd';
$query_vars[] = 'categorie';
return $query_vars;
}
add_filter('query_vars', 'wpd_query_var' , 10, 1 );
function wpd_post_rewrite(){
add_rewrite_rule(
'international/([^/]+)/?$',
'index.php?name=$matches[1]&post_type=film&categorie=international',
'top'
);
add_rewrite_rule(
'france/([^/]+)/?$',
'index.php?name=$matches[1]&post_type=film&categorie=france',
'top'
);
add_rewrite_rule(
'projections_dvd/([^/]+)/?$',
'index.php?name=$matches[1]&post_type=film&categorie=projections_dvd',
'top'
);
add_rewrite_rule(
'international/theatrical/([^/]+)/?$',
'index.php?name=$matches[1]&post_type=film&categorie=theatrical',
'top'
);
}
add_action( 'init', 'wpd_post_rewrite' );
function wpd_abstract_template( $single_template ){
global $wp_query;
if ( isset( $wp_query->query_vars['categorie'] ) ) {
$categorie = $wp_query->query_vars['categorie'] ;
if($categorie == 'international' && in_category('international')) {
return locate_template( 'film_international_template.php', false ) ;
} elseif($categorie == 'theatrical' && in_category('theatrical')) {
return locate_template( 'film_international_theatrical_template.php', false ) ;
} elseif($categorie == 'france' && in_category('france')) {
return locate_template( 'film_france_template.php', false ) ;
} elseif($categorie == 'projections_dvd' && in_category('projections_dvd')) {
return locate_template( 'film_projections_dvd_template.php', false ) ;
} else {
return locate_template( '404.php', false ) ;
}
}
return locate_template( 'single.php', false ) ;
}
add_filter( 'single_template', 'wpd_abstract_template' );