
WordPress主题函数get_category_by_slug()知识点。
描述:
用法:
php get_category_by_slug( $slug ); ?>
参数:
$slug
(string) (必填) 分类别名
默认值:None
示例:
idObj = get_category_by_slug('category-slug'); $id = $idObj->term_id; ?>
源文件:
/** * Retrieve category object by category slug. * * @since 2.3.0 * * @param string $slug The category slug. * @return object Category data object */ function get_category_by_slug( $slug ) { $category = get_term_by( 'slug', $slug, 'category' ); if ( $category ) _make_cat_compat( $category ); return $category; }

博悦天下










