Skip to content

Commit 89f26de

Browse files
Docs: Clarify documentation for the template_redirect hook.
Follow-up to [1910], [13252], [25702]. Props apermo, SergeyBiryukov. Fixes #64018. git-svn-id: https://develop.svn.wordpress.org/trunk@60791 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8bc30c9 commit 89f26de

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/wp-includes/template-loader.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
<?php
22
/**
3-
* Loads the correct template based on the visitor's url
3+
* Loads the correct template based on the visitor's URL
44
*
55
* @package WordPress
66
*/
77
if ( wp_using_themes() ) {
88
/**
99
* Fires before determining which template to load.
1010
*
11+
* This action hook executes just before WordPress determines which template page to load.
12+
* It is a good hook to use if you need to do a redirect with full knowledge of the content
13+
* that has been queried.
14+
*
15+
* Note: Loading a different template is not a good use of this hook. If you include another template
16+
* and then use `exit()` or `die()`, no subsequent `template_redirect` hooks will be run, which could
17+
* break the site’s functionality. Instead, use the {@see 'template_include'} filter hook to return
18+
* the path to the new template you want to use. This will allow an alternative template to be used
19+
* without interfering with the WordPress loading process.
20+
*
1121
* @since 1.5.0
1222
*/
1323
do_action( 'template_redirect' );

0 commit comments

Comments
 (0)