黄聪

论SEO对人类的重要性,请看我的博客:hcsem.com

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

<?
    global $wp_query;
    $cat_ID = get_query_var('cat');
    $category = get_category($cat_ID);
    echo $category->slug;

?>

 

get_category()    根据分类ID获得指定分类全部信息,以数组或是对象的形式返回,以下是该函数的返回值示例:

stdClass Object
(

     //ID 分类和标签混编

    [term_id] => 5

    //分类名

    [name] => Cat Name

    //分类别名

    [slug] => cat

    //N/A

    [term_group] => 0

    //同 term_id

    
[term_taxonomy_id] => 5

    //分类法,也就是分类还是标签

    [taxonomy] => category

    //分类描述

    [description] =>

    //父级ID

    [parent] => 70

    //N/A

    [count] => 0

    //分类ID

    [cat_ID] => 5

    //N/A

    [category_count] => 0

    //同 description

    [category_description] =>

    //同 name

    
[cat_name] => Category Name

    //同 slug

    [category_nicename] => category-name

    //同 parent

    [category_parent] => 70

)

 

get_cat_ID()    根据分类名称获取分类ID

get_cat_name()    根据分类ID获取分类名称

get_category_link()    根据分类ID获取分类的链接URL

posted on 2014-11-03 20:25  黄聪  阅读(9265)  评论(0编辑  收藏  举报