Make WordPress Core

Changeset 60791


Ignore:
Timestamp:
09/22/2025 02:25:55 PM (29 hours ago)
Author:
SergeyBiryukov
Message:

Docs: Clarify documentation for the template_redirect hook.

Follow-up to [1910], [13252], [25702].

Props apermo, SergeyBiryukov.
Fixes #64018.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/template-loader.php

    r47855 r60791  
    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
     
    88    /**
    99     * Fires before determining which template to load.
     10     *
     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.
    1020     *
    1121     * @since 1.5.0
Note: See TracChangeset for help on using the changeset viewer.