WordPress开发者和主题制作者的搜索引擎



get_category_by_slug ›

Since2.3.0
已弃用n/a
get_category_by_slug ( $slug )
参数:
  • (string) $slug The category slug.
    Required: Yes
返回:
  • (object) Category data object
定义在:
文档:

Retrieve category object by category slug.



源码

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

	return $category;
}