Hello,
Is it possible to have more than one “single-event.php” template. I would like to have a second one used only on a special category (“school” for example). And by the way use also a duplicated “event-meta-event-single.php” to be used only for this same category.
Thanks for your help.
Nicolas Massart
Hi Nicolas,
You can do one of two things:
1) Hook into template_include
and use has_term( 'term-slug', 'event-category' )
to decide which template to load (the function should return the path to the desired template). Please note, you should just return the filtered value if is_singular( 'event' )
is not false.
2) In your single-event.php
simply check , has_term( 'term-slug', 'event-category' )
and display the content accordingly. You could even just have single-event.php
as a “shell” which just decides which category-specific template to load.
Stephen Harris
Thanks, I used the second option. Here is the code I used if an another newbie in php like me wants to achieve the same result ;o)
<?php
// choose which meta template to use according to category
if( has_term( 'ecole', 'event-category' ) ){
eo_get_template_part('event-meta','event-single-ecole');
}else{
eo_get_template_part('event-meta','event-single');
} ?>
Nicolas Massart