Why would a Post Taxonomy request load wrong template?

I am in a pickle here; I don’t like to ask these sort of questions, however, I don’t know who else to ask for help.

I keep getting the page.php template for a Post category request. The rule matched is correct category/(.+?)/?$ according to my debugger. The debugger also says that the category.php template is being displayed, however, I have also a Show Current Template plugin that says that page.php is being loaded. And in fact it is page.php template.

One attempt was to include the category.php template using template_include filter… but that didn’t work. I even tried to include this code without any conditional statements and page.php keeps getting loaded for this request:

public function redirect_blog_catgory_template( $template ) {

    $new_template = locate_template( array( 'category.php' ) ); 
    if ( '' != $new_template ) {
        return $new_template ;
    }

    return $template;   
}

add_filter('template_include', array( $this, 'redirect_blog_catgory_template' ), 2000 );

This filter worked for all other requests except the post category request.

How does one go about debugging this? It makes no sense…

Read more here: Why would a Post Taxonomy request load wrong template?

Leave a Reply

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