WordPress Find Categories By Name
The below works for both categories, and other custom taxonomies (e.g genres) you may have. Find category by an exact match$cat = get_term_by( 'name', $cat_name, 'category' );Find category by partial match anywhere
$categories = get_terms( 'category', array( 'name__like' => 'cat_name' ) );Find category by partial match from the start of the string
$categories = get_terms( 'category', array( 'search' => 'cat_name' ) );
Be First to Comment