Often the type of WordPress projects I work on don’t need the comments enabled. While there are various plugins and snippets out there, I wanted a simple solution that was re-useable and easily dropped into the mu-plugins directory. mu-plugins in WordPress are Must-use Plugins that are always loaded and don’t appear in the plugins list inside WP Admin. To install simply add the PHP file to wp-content/mu-plugins/ and then magically everything comment related will disappear. Note: the comments table in the database will remain.
Loading a different template is NOT proper use of this hook! Use the template_include hook to return the path to the new template you want to use.
template_redirect is great hook to use when you need to redirect users elsewhere after WordPress has made it’s main query and all objects are available. However, since no output has been sent to the browser at this point it provides a lot of flexibility.
Below is an example of how WordPress’s template_redirect hook can be used. It’s a function I used on project to publicly disable certain post type archives while development and content were still in progress.