As usual, let’s start by pasting the function in your functions.php file:
function get_category_id($cat_name){ $term = get_term_by('name', $cat_name, 'category'); return $term->term_id; }
Once you saved the file, just call the function with your category name as a parameter. Example:
$category_ID = get_category_id('WordPress Tutorials');
Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!