A WordPress-centric search engine for devs and theme authors



get_cat_id ›

Since1.0.0
Deprecatedn/a
get_cat_id ( $cat_name )
Parameters:
  • (string) $cat_name Category name.
    Required: Yes
Returns:
  • (int) 0, if failure and ID of category on success.
Defined at:
Codex:

Retrieve the ID of a category from its name.



Source

function get_cat_ID( $cat_name ) {
	$cat = get_term_by( 'name', $cat_name, 'category' );
	if ( $cat ) {
		return $cat->term_id;
	}
	return 0;
}