Hello,
Thanks. I think that is what I do, passing an argument, with my query_vars is_france , is_international … The issue I have I think, is with my url_rewrite, which works with articles, but not with custom post types… I think with that code I am close to the solution, do you have a clue how I can get it to work with custom post types ?
function wpd_query_var( $query_vars ) {
$query_vars[] = 'is_international';
$query_vars[] = 'is_france';
$query_vars[] = 'is_projections_dvd';
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]&is_international=1',
'top'
);
add_rewrite_rule(
'france/([^/]+)/?$',
'index.php?name=$matches[1]&is_france=1',
'top'
);
add_rewrite_rule(
'projections_dvd/([^/]+)/?$',
'index.php?name=$matches[1]&is_projections_dvd=1',
'top'
);
}
add_action( 'init', 'wpd_post_rewrite' );
function wpd_abstract_template( $single_template ){
global $wp_query;
//print_r($wp_query);
if ( isset( $wp_query->query_vars['is_international'] ) ) {
if(in_category('international')) {
return locate_template( 'film_international_template.php', false ) ;
} else {
return locate_template( '404.php', false ) ;
}
}
if ( isset( $wp_query->query_vars['is_france'] ) ) {
if(in_category('france')) {
return locate_template( 'film_france_template.php', false ) ;
} else {
return locate_template( '404.php', false ) ;
}
}
if ( isset( $wp_query->query_vars['is_projections_dvd'] ) ) {
if(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' );