Looking to pull the category ID of a specific page in WordPress that is listing all posts using that specific category. Tried the below but not working. I am able to get the category name using single_term_title
.
$category = single_term_title("", false);
$catid = get_cat_ID( $category );
$category
is displaying "Entertainment" for example. But I also need the ID of "Entertainment". How would I go about this?
Alternative -
EDIT: Above function is deprecated please use
get_the_category()
I use the get_queried_object function to get the current category on a category.php template page.
Jordan Eldredge is right, get_the_category is not suitable here.