WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the Query Multiple Taxonomies plugin to get a page of search results (all of which are a custom post type - car). If any search terms are added, so the url looks like this:


then the archive.php template is used. However, if the user clicks search without adding any terms, so the url looks like this:


then index.php is used instead. I'd like to ensure this 'empty' search uses the archive.php template too.

These bits from my functions file may be relevant:

// Ensure Custom Post Type is included in query

add_action( 'pre_get_posts', 'add_my_post_types_to_query' );

function add_my_post_types_to_query( $query ) {
    if ( is_home() && $query->is_main_query() )
        $query->set( 'post_type', array('car' ) );
    return $query;

// Tweaks to taxonomy layered search

function my_qmt_base_url( $base ) {
    return get_bloginfo('home').'/car/';
add_filter( 'qmt_base_url', 'my_qmt_base_url' );

function my_qmt_reset_url( $reset_url ) {
    $url = get_permalink();
    return $url;

add_filter( 'qmt_reset_url', 'my_qmt_reset_url' );

Any help would be much appreciated!


share|improve this question
up vote 1 down vote accepted

You could filter template_include:

add_filter( 'template_include', 'wpse_97347_force_archive' );

function wpse_97347_force_archive( $template )
    if ( isset ( $_GET['makemodel'] ) && empty ( $_GET['makemodel'] ) )
        return get_archive_template();

    return $template;

Not tested.

share|improve this answer
Wow, thanks for the speedy reply! Works first time! – Grahamd Apr 26 '13 at 14:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.