template_include vs template_redirect

WordPress has a filter called ‘template_include’ and it also has an action called ‘template_redirect’.  The filter allows you to change what template file to use by returning a file path while the action is usually used to write whatever you need to and then exit.

According to this issue for bbPress template_redirect can cause incompatibility issues with other plugins using this hook.  Also using this hook exits WordPress abruptly not allowing WordPress to run through it’s normal procedure (according to one blog).  It is probably best to use ‘template_include’ unless you have a specific reason not to.

Tagged with: ,

Leave a Reply

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