get_category_by_slug

函数


get_category_by_slug ( $slug )
参数
  • (string)
    $slug
    The category slug.
    Required:
返回值
  • (object|false) Category data object on success, false if not found.
定义位置
  • wp-includes/category.php
    , line 187
引入
2.3.0
弃用

按类别名称检索一个类别对象。

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

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

	return $category;
}