WordPress at a glance

get_cat_ID() WP 1.0

Retrieve the ID of a category from its name.

Works based on: get_term_by()

No Hooks.


Int. 0, if failure and ID of category on success.


get_cat_ID( $cat_name ) // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid;
$cat_name(string) (required)
Category name.


Since 1.0.0 Introduced.

Code of get cat ID: wp-includes/category.php WP 5.4.2

function get_cat_ID( $cat_name ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	$cat = get_term_by( 'name', $cat_name, 'category' );
	if ( $cat ) {
		return $cat->term_id;
	return 0;

Related Functions

From category: Categories

No comments
        Log In . Register