get_cat_ID( string $cat_name )
Retrieve the ID of a category from its name.
Description Description
Parameters Parameters
- $cat_name
-
(string) (Required) Category name.
Return Return
(int) 0, if failure and ID of category on success.
Source Source
File: wp-includes/category.php
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; }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Example:
Useful for a function such as
category_description()
that requires a category’s ID: