Get current category ID of WordPress page
The current category ID is in the global $cat variable, when you are in a category page you can get it as follows.
<?php if (is_category()) { $category = get_category(get_query_var('cat')); $cat_id = $category->cat_ID; } ?> |