Use different template regarding to category

WordPress Event Management, Calendars & Registration Forums General Question Use different template regarding to category

This topic contains 2 replies, has 2 voices, and was last updated by  Nicolas Massart 1 year, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #26610


    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)

                    // choose which meta template to use according to category
                    if( has_term( 'ecole', 'event-category' ) ){
    } ?>
    Nicolas Massart
Viewing 3 posts - 1 through 3 (of 3 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.