A WordPress-centric search engine for devs and theme authors



get_category_by_slug ›

Since2.3.0
Deprecatedn/a
get_category_by_slug ( $slug )
Parameters:
  • (string) $slug The category slug.
    Required: Yes
Returns:
  • (object) Category data object
Defined at:
Codex:

Retrieve category object by category slug.



Source

function get_category_by_slug( $slug ) {
	$category = get_term_by( 'slug', $slug, 'category' );
	if ( $category ) {
		_make_cat_compat( $category );
	}

	return $category;
}