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
There is category_exists()
function, but it seems to be for internal use in admin so you can try term_exists()
instead.