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.
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.
You must be logged in to post a comment.
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 you want to check if you are in a specific term ( like
is_category
) you can use is_taxif you want to check if your object (post) is in a specific term ( like
in_category
) you can use is_object_in_term()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:
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:
and the you can use this to find the custom post type:
Which I originally found here:
If is custom post type
Hope this helps!