How to template_redirect wordpress Example

Quick code snippet showing basic use of the WordPress template_redirect action hook. This is provided as a quick copy/paste reference for WordPress developers. This hook is useful for customizing any functionality requiring full query information.

function shapeSpace_template_redirect() {
	
	if (is_page('about')) {
		
		// die('This is the About Page');
		
	}
	
}
add_action('template_redirect', 'shapeSpace_template_redirect');

Add this code via plugin or theme functions.php. You can customize the conditional logic or whatever you need to do. Learn more about template_redirect at the WordPress Codex.

See also  Check if Product Belongs to a Product Category or Tag

Leave a Reply

Your email address will not be published. Required fields are marked *