template_redirect action-hookWP 1.5.0

Fires before determining which template to load.

Usage

add_action( 'template_redirect', 'wp_kama_template_redirect_action' );

/**
 * Function for `template_redirect` action-hook.
 * 
 * @return void
 */
function wp_kama_template_redirect_action(){

	// action...
}

Changelog

Since 1.5.0 Introduced.

Where the hook is called

In file: /wp-includes/template-loader.php
template_redirect
wp-includes/template-loader.php 13
do_action( 'template_redirect' );

Where the hook is used in WordPress

wp-includes/customize/class-wp-customize-selective-refresh.php 146
add_action( 'template_redirect', array( $this, 'handle_render_partials_request' ) );
wp-includes/default-filters.php 312
add_action( 'template_redirect', 'rest_output_link_header', 11, 0 );
wp-includes/default-filters.php 343
add_action( 'template_redirect', 'wp_shortlink_header', 11, 0 );
wp-includes/default-filters.php 444
add_action( 'template_redirect', 'wp_old_slug_redirect' );
wp-includes/default-filters.php 599
add_action( 'template_redirect', 'redirect_canonical' );
wp-includes/default-filters.php 600
add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
wp-includes/default-filters.php 621
add_action( 'template_redirect', '_wp_admin_bar_init', 0 );
wp-includes/ms-default-filters.php 74
add_action( 'template_redirect', 'maybe_redirect_404' );
wp-includes/sitemaps/class-wp-sitemaps.php 68
add_action( 'template_redirect', array( $this, 'render_sitemaps' ) );