How to control template resolution if both Author and Category filter in place?

The following url resolves to the category template:
http://localhost/author/myusername/?category_name=somecategory

I have a category-somecategory.php template and just a generic author.php template. Is there any way to make such a url use the author.php template instead of the category-somecategory.php? If not how can I filter on both category and author and force it to use the author template?

Related posts

Leave a Reply

2 comments

  1. You could change the template loaded by hooking onto template_include, checking if is_author and is_category are both set, then switch the template for inclusion to the author template instead.

    Give this a shot..

    add_filter( 'template_include', 'my_template_setter' );
    function my_template_setter( $template ) {
        if( is_author() && is_category() && is_archive() )
            $template = get_author_template();
        return $template;
    }
    

    You can do any number of conditional checks here before modifying which template gets loaded.

    WordPress has several template fetching functions available already, i’ve used one in the example, but here’s a list for quick reference…

    get_404_template()
    get_search_template()
    get_taxonomy_template()
    get_front_page_template()
    get_home_template()
    get_attachment_template()
    get_single_template()
    get_page_template()
    get_category_template()
    get_tag_template()
    get_author_template()
    get_date_template()
    get_archive_template() 
    

    Hope that helps..