get_category_by_slug( string $slug ): object|false

Retrieves a category object by category slug.

Parameters

$slugstringrequired
The category slug.

Return

object|false Category data object on success, false if not found.

More Information

Same is achieved by:
get_term_by('slug', $slug, 'category');

Source

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

	if ( $category ) {
		_make_cat_compat( $category );
	}

	return $category;
}

Changelog

VersionDescription
2.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.