wpseek.com
A WordPress-centric search engine for devs and theme authors



get_category_by_slug › WordPress Function

Since2.3.0
Deprecatedn/a
get_category_by_slug ( $slug )
Parameters:
  • (string) $slug The category slug.
    Required: Yes
Returns:
  • (object|false) Category data object on success, false if not found.
Defined at:
Codex:

Retrieves a 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;
}