get_cat_ID

Definition:
function get_cat_ID( $cat_name='General' ) {}

Retrieve the ID of a category from its name.

Parameters

  • string $cat_name: Optional. Default is ‘General’ and can be any category name.

Return values

returns:0, if failure and ID of category on success.

Source code

function get_cat_ID( $cat_name='General' ) {

	$cat = get_term_by( 'name', $cat_name, 'category' );

	if ( $cat )

		return $cat->term_id;

	return 0;

}

1264

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: