Change Theme Template in WordPress

If you need to change the template for WordPress based on the category of the post/page, on whether or not the current post is a page or a post, etc…, then you want to use the action hook template_redirect. For example, you may want to use a variation of the following code: add_action(‘template_redirect’, ‘your_redirect_function’); function