ITeye博客

根据别名查找分类属性

haimingyoung · 2016-02-24 09:27 · WordPress · 编程语言 · Markdown

/**
 * 根据别名查找分类属性
 * @param type $slug
 * @param type $type
 * @return type
 */
function getCategoryProperty($slug,$type){
   
    $property = null;
    $catname = get_category_by_slug($slug);
   
    if($type == 'name'){
        $property = $catname->name;
    }
   
    if($type == 'slug'){
        $property = $catname->slug;
    }
   
    if($type == 'id'){
        $property = $catname->cat_ID;
    }
   
    if($type == 'parent'){
        $property = $catname->parent;
    }
   
    if($type == 'link'){
        $property = get_category_link($catname->cat_ID);
    }
   
    return $property;
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。