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 want to create conditional tags for the business directory categories as the conditional tags which are provided are for normal categories.which do not work for the business directory categories.can i do ths? if yes, then how?

thanks in advance.

share|improve this question
    
what the name of the plugin you are using to create the business directory categories? –  Bainternet Aug 3 '11 at 12:20
add comment

2 Answers

you can use has_term to check if a post as a term which that is what "business directory categories" are (custom taxonomy terms). something like:

if (has_term( $term, $taxonomy, $post_id )){
//do your thing
}

if you want to check if you are in a specific term ( like is_category) you can use is_tax

if (is_tax( $taxonomy, $term )){
//do stuff
}

if you want to check if your object (post) is in a specific term ( like in_category) you can use is_object_in_term()

if (is_object_in_term( $object_id, $taxonomy, $terms) ){
//do stuff
}
share|improve this answer
add comment

I'm not sure what your "business directory" categories are. Are you using a specific plugin to create this business directory?

Taking a stab in the dark, you've got two options. If these categories are the same categories under the "Posts" taxonomy, then you could use this:

is_category('my-business-category');

If, however, your using a special plugin that adds its own custom taxonomy (meaning you aren't using the "posts" but you have a "directory" section in WP-admin, and you want to check if that is what the user is looking at, you would have to use something like this:

Put this in your functions.php:

function is_post_type($type){
    global $wp_query;
    if($type == get_post_type($wp_query->post->ID)) return true;
    return false;
}

and the you can use this to find the custom post type:

is_post_type('business_post_type')

Which I originally found here:

If is custom post type

Hope this helps!

share|improve this answer
    
not sure if that's what she meant and your code wont check for custom taxonomy but for a post type. –  Bainternet Aug 3 '11 at 13:00
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.