How do I determine if a category exists by ID?

I know I can get a categories ID by calling get_cat_ID(‘category-slug’), however, what is the method to call to determine if a category exists by ID when you don’t know the slug?

In other words, I need to determine if category id 1 exists. What’s the function for this?

Can I just use if(get_category(1)) {//do something?}

2 Answers
2

There is category_exists() function, but it seems to be for internal use in admin so you can try term_exists() instead.

Leave a Comment