WordPress action hook · part of WordPress core

template_redirect

A WordPress core action that 19 plugins also fire themselves, running on 1.1M+ sites between them.

How to use template_redirect

It's an action: your callback runs at that point. Nothing needs to be returned. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_action( 'template_redirect', function() {
	// Your code runs here.
}, 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 →

19 plugins that fire template_redirect

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 do_action( 'template_redirect' ) classes/wp-security-process-renamed-login-page.php:272
  2. Product Filter for WooCommerce by WBW icon Product Filter for WooCommerce by WBW50,000+ installs do_action( 'template_redirect' ) modules/woofilters/class-woobewoo-pf-woofilters-controller.php:666
  3. Visual Composer Website Builder icon Visual Composer Website Builder30,000+ installs do_action( 'template_redirect' ) visualcomposer/Modules/Elements/AjaxShortcode/Controller.php:118
  4. MasterStudy LMS WordPress Plugin icon MasterStudy LMS WordPress Plugin10,000+ installs do_action( 'template_redirect' ) _core/stm-lms-templates/course-player.php:299
  5. Groovy Menu Plugin (Free) icon Groovy Menu Plugin (Free)4,000+ installs do_action( 'template_redirect' ) includes/modules/virtualpages/inc/VirtualPagesTemplateLoader.php:20
  6. Listdom: AI-powered Business Directory with Classifieds Ads Listings icon Listdom: AI-powered Business Directory with Classifieds Ads Listings1,000+ installs do_action( 'template_redirect' ) app/includes/hooks.php:161
  7. Login Armor icon Login Armor600+ installs do_action( 'template_redirect' ) includes/class-hide-login.php:1857
  8. Read More Login icon Read More Login200+ installs do_action( 'template_redirect' ) controllers/ReadMoreLoginController.php:580
  9. Give as you Live icon Give as you Live100+ installs do_action( 'template_redirect' ) admin/buttons_delete.php:34
  10. Appful icon Appful40+ installs do_action( 'template_redirect' ) includes/wp/WPPageManager.php:78
  11. Hiperlink Security icon Hiperlink Security30+ installs do_action( 'template_redirect' ) modules/login-url/includes/answer.php:122
  12. Marcelo Site Connector icon Marcelo Site Connector20+ installs do_action( 'template_redirect' ) marcelo-site-connector.php:10283
  13. AQT alloq Tempo icon AQT alloq TempoFewer than 10 installs do_action( 'template_redirect' ) src/Modules/Login.php:365
  14. Dolphy icon DolphyFewer than 10 installs do_action( 'template_redirect' ) classes/Template/Loader.php:13
  15. Customer Service to Content Marketing Converter by Produck icon Customer Service to Content Marketing Converter by ProduckFewer than 10 installs do_action( 'template_redirect' ) vpage/templateloader.php:27
  16. GdprAccept Lite icon GdprAccept LiteFewer than 10 installs do_action( 'template_redirect' ) inc/Api/VirtualPages/TemplateLoader.php:15
  17. WPDevHub Troubleshooting Guides icon WPDevHub Troubleshooting GuidesFewer than 10 installs do_action( 'template_redirect' ) classes/vp/class.DSCF_DTG_VirtualPages_TemplateLoader.php:21
  18. WPDevHub Link Manager icon WPDevHub Link ManagerFewer than 10 installs do_action( 'template_redirect' ) classes/vp/class.DSCF_DLM_VirtualPages_TemplateLoader.php:21
  19. Fuzzy Filter icon Fuzzy FilterFewer than 10 installs do_action( 'template_redirect' ) modules/filters/class-view.php:876

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.