Title: Template override through code
Last modified: November 25, 2021

---

# Template override through code

 *  Resolved [nervino](https://wordpress.org/support/users/nervino/)
 * (@nervino)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/template-override-through-code/)
 * Hello, I want to override a wp-event-manager template through code.
    [Wp Event Manager documentation](https://wp-eventmanager.com/knowledge-base/template-files-override/)
   says to apply a filter in this way: `return apply_filters( 'event_manager_locate_template',
   $template, $template_name, $template_path );`
 * At the end of my function.php I put:
    `return apply_filters( 'event_manager_locate_template','/
   wp-content/themes/Divi-child/wp-event-manager/', 'content-event_listing_custom.
   php', 'content-event_listing' );` but nothing change…
 * Is my code correct?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Hitesh Makvana](https://wordpress.org/support/users/hiteshmakvana/)
 * (@hiteshmakvana)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/template-override-through-code/#post-15116908)
 * Hi [@nervino](https://wordpress.org/support/users/nervino/)
    You don’t need to
   override template via code. By default it will override if you create folder 
   here /wp-content/themes/Divi-child/wp-event-manager/
 * Once the folder is created copy the template file from the plugin and put it 
   on the above path. [https://wp-eventmanager.com/knowledge-base/template-files-override/](https://wp-eventmanager.com/knowledge-base/template-files-override/)
 * It should fine.
 * Thank you
    -  This reply was modified 4 years, 6 months ago by [Hitesh Makvana](https://wordpress.org/support/users/hiteshmakvana/).
 *  Thread Starter [nervino](https://wordpress.org/support/users/nervino/)
 * (@nervino)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/template-override-through-code/#post-15120290)
 * Thank you for your reply, Hitesh. I know I can override templates in that way(
   please, see the path I’ve put in my function.php). I was trying to implement 
   the override through code in order to use different templates based on conditions(
   IF ELSE..).
    However, I solved using a different approach, inserting the conditions
   inside the template.
 *  [Hitesh Makvana](https://wordpress.org/support/users/hiteshmakvana/)
 * (@hiteshmakvana)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/template-override-through-code/#post-15124049)
 * Hi [@nervino](https://wordpress.org/support/users/nervino/)
 * Glad to hear that you have solved it.
 * Thank you

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Template override through code’ is closed to new replies.

 * ![](https://ps.w.org/wp-event-manager/assets/icon-256x256.png?rev=1622826)
 * [WP Event Manager – Events Calendar, Registrations, Sell Tickets with WooCommerce](https://wordpress.org/plugins/wp-event-manager/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-event-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-event-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-event-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-event-manager/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Hitesh Makvana](https://wordpress.org/support/users/hiteshmakvana/)
 * Last activity: [4 years, 6 months ago](https://wordpress.org/support/topic/template-override-through-code/#post-15124049)
 * Status: resolved