Uses
Uses | Description |
---|---|
wp-includes/taxonomy.php: get_term_by() | Get all Term data from database by Term field and data. |
Retrieves the ID of a category from its name.
(string) (Required) Category name.
(int) Category ID on success, 0 if the category doesn't exist.
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; }
Version | Description |
---|---|
1.0.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_cat_id