[wp-hackers] if category exists

Daniel Cameron dan at sproutventure.com
Thu Mar 19 19:09:51 GMT 2009


Basically I have category links hardcoded into my theme template like so: <li
id="nav-linkt" <?php if (is_category('cat')) { echo "class=\"active_link\""
; } ?>>
<a href="<?php echo
get_category_link(get_category_by_slug('cat'));?>">Cat</a>
</li>

which is fine but if the category doesn't exist (in the example above 'cat')
then the theme bombs.

Is there a way to wrap this list item with something like <?php if
category_exists { ?

I know that function doesn't exist but anything similar without having to
hard code a query?

Thanks all.


More information about the wp-hackers mailing list