WordPress filter hook · part of WordPress core

template_include

A WordPress core filter that 30 plugins also fire themselves, running on 1.7M+ sites between them.

“This filter is documented in wp-includes/template-loader.php”

How to use template_include

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'template_include', function( $template ) {
	// Change $template here.
	return $template;
}, 10, 1 );

Argument names come from All-In-One Security (AIOS)'s source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

30 plugins that fire template_include

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. All-In-One Security (AIOS) icon All-In-One Security (AIOS)1+ million installs apply_filters( 'template_include', $template ) classes/wp-security-process-renamed-login-page.php:277
  2. SiteGuard WP Plugin icon SiteGuard WP Plugin600,000+ installs apply_filters( 'template_include', $template ) classes/siteguard-rename-login.php:680
  3. Visual Composer Website Builder icon Visual Composer Website Builder30,000+ installs apply_filters( 'template_include', $template ) visualcomposer/Modules/FrontView/MaintenanceModeController.php:101
  4. FeedWordPress icon FeedWordPress8,000+ installs apply_filters( 'template_include', $template ) feedwordpress.php:1478
  5. Ultimate 410 Gone Status Code icon Ultimate 410 Gone Status Code6,000+ installs apply_filters( 'template_include', $template ) src/Plugin.php:40
  6. WP Fusion Lite icon WP Fusion Lite4,000+ installs apply_filters( 'template_include', $template ) includes/class-access-control.php:634
  7. Groovy Menu Plugin (Free) icon Groovy Menu Plugin (Free)4,000+ installs apply_filters( 'template_include', apply_filters( 'virtual_page_template', $template ) ) includes/modules/virtualpages/inc/VirtualPagesTemplateLoader.php:22
  8. Login Armor icon Login Armor600+ installs apply_filters( 'template_include', $template ) includes/class-hide-login.php:1863
  9. Diamond Sierra Site Defense icon Diamond Sierra Site Defense100+ installs apply_filters( 'template_include', get_404_template() ) includes/class-dssd-login-url.php:264
  10. Show Template icon Show Template60+ installs apply_filters( 'template_include', $this->template ) show-template.php:44
  11. Mask My Admin icon Mask My Admin50+ installs apply_filters( 'template_include', $template ) includes/class-url-masking.php:296
  12. Hiperlink Security icon Hiperlink Security30+ installs apply_filters( 'template_include', $template ) modules/login-url/includes/answer.php:128
  13. Post Forking icon Post Forking20+ installs apply_filters( 'template_include', $template ) includes/preview.php:66
  14. Marcelo Site Connector icon Marcelo Site Connector20+ installs apply_filters( 'template_include', $template ) marcelo-site-connector.php:10317
  15. Add Page From Template icon Add Page From Template10+ installs apply_filters( 'template_include', $templatePath ) includes/class-loader.php:202
  16. Post-Specific Widgets icon Post-Specific Widgets10+ installs apply_filters( 'template_include', $template ) post-specific-widgets-functions.php:47
  17. Protect Pages & Posts icon Protect Pages & Posts10+ installs apply_filters( 'template_include', $template ) includes/post-page-loader.php:98
  18. Forensix Digital icon Forensix Digital10+ installs apply_filters( 'template_include', $template ) src/Apps/Maintenance/MaintenanceApp.php:399
  19. StaticPush by Quintaphon icon StaticPush by Quintaphon10+ installs apply_filters( 'template_include', $template ) includes/class-cfsp-feeds.php:60
  20. Taxonomy Templates icon Taxonomy Templates10+ installs apply_filters( 'template_include', $template ) taxonomy-templates.php:38
  21. AQT alloq Tempo icon AQT alloq TempoFewer than 10 installs apply_filters( 'template_include', '' !== $template ? $template : get_index_template() ) src/Modules/Login.php:370
  22. SmartCloud Agent Composer icon SmartCloud Agent ComposerFewer than 10 installs apply_filters( 'template_include', $resolved ) src/Execution/Rendered_Preview_Service.php:316
  23. Neksio Login & File Security icon Neksio Login & File SecurityFewer than 10 installs apply_filters( 'template_include', $template ) includes/class-login-url-rewriter.php:321
  24. PathGuard Redirects icon PathGuard RedirectsFewer than 10 installs apply_filters( 'template_include', $template ) includes/URLB_Blocker.php:188
  25. Dolphy icon DolphyFewer than 10 installs apply_filters( 'template_include', apply_filters('virtual_page_template', $template) ) classes/Template/Loader.php:16
  26. WPS Protect: Login URL & Security Headers icon WPS Protect: Login URL & Security HeadersFewer than 10 installs apply_filters( 'template_include', $template ) src/Login/Gate.php:407
  27. GdprAccept Lite icon GdprAccept LiteFewer than 10 installs apply_filters( 'template_include', apply_filters( 'virtual_page_template', $template ) ) inc/Api/VirtualPages/TemplateLoader.php:17
  28. WPDevHub Troubleshooting Guides icon WPDevHub Troubleshooting GuidesFewer than 10 installs apply_filters( 'template_include', apply_filters( 'virtual_page_template', $template ) ) classes/vp/class.DSCF_DTG_VirtualPages_TemplateLoader.php:53
  29. WPDevHub Link Manager icon WPDevHub Link ManagerFewer than 10 installs apply_filters( 'template_include', apply_filters( 'virtual_page_template', $template ) ) classes/vp/class.DSCF_DLM_VirtualPages_TemplateLoader.php:53
  30. oOMF! Access icon oOMF! AccessFewer than 10 installs apply_filters( 'template_include', $template ) includes/Frontend/class-hideadmin.php:582

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.