get_category_by_slug

Advertisement

Summery Summery

Retrieves a category object by category slug.

Syntax Syntax

get_category_by_slug( string $slug )

Parameters Parameters

$slug

(string) (Required) The category slug.

Return Return

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

Source Source

File: wp-includes/category.php

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

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

	return $category;
}

Advertisement

Changelog Changelog

Changelog
Version Description
2.3.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.