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.

Return

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

Usage

get_cat_ID( $cat_name );
$cat_name(string) (required)
Category name.

Code of get_cat_ID: wp-includes/category.php VER 4.9.8

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

Related Functions

From category: Categories

No comments
    Hello, !     Log In . Register