Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to do a template redirect in my wordpress but with partial success

  function ahaali_qa_theme_redirect(){
    global $wp;
    $plugindir = dirname(__FILE__);

    if(is_archive()){
        $tname = 'archive-question.php';
        if(file_exists(TEMPLATEPATH.'/'.$tname)){
            $returntemplate = TEMPLATEPATH.'/'.$tname;
        }else{
            $returntemplate = $plugindir.'/default-template/'.$tname;
        }
        ahaali_do_theme_redirect($returntemplate);
    }elseif(is_single()){
        $tname = 'single-question.php';
        if(file_exists(TEMPLATEPATH.'/'.$tname)){
            $returntemplate = TEMPLATEPATH.'/'.$tname;
        }else{
            $returntemplate = $plugindir.'/default-template/'.$tname;
        }
        ahaali_do_theme_redirect($returntemplate);
    }elseif(is_archive() && is_tax('question_category')){
        $tname = 'taxonomy-question_category.php';
        if(file_exists(TEMPLATEPATH.'/'.$tname)){
            $returntemplate = TEMPLATEPATH.'/'.$tname;
        }else{
            $returntemplate = $plugindir.'/default-template/'.$tname;
        }
        ahaali_do_theme_redirect($returntemplate);
    }
}

everything works except the is_tax() , can somebody explain me how to do this or what I'm doing wrong ?

Thank you !

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

this is just a simple php syntax issue- anything that meets the conditions is_archive() && is_tax('question_category') will also return true for the first if(is_archive()), so you're code is never reaching that test.

share|improve this answer
    
Thank you , you were wight ! –  Paul Dumitru Jun 16 '12 at 13:46
    
Also, is_tax() is deprecated as of 3.0. You should be using taxonomy_exists() instead. –  Evan Mattson Jun 16 '12 at 13:53
    
is_tax() is not deprecated. What is deprecated is is_taxonomy() (in fact, you've actually linked to this function). –  Andrea Sciamanna Jul 2 '13 at 10:44
add comment

Your Answer

 
discard

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.