如何在 WordPress 中获取自定义帖子类型的分类 slug URL?

时间:2021-01-25 05:03:54

标签: wordpress

我有这个数组:

[0] => WP_Term Object
    (
        [term_id] => 19
        [name] => Accessories
        [slug] => accessories
        [term_group] => 0
        [term_taxonomy_id] => 19
        [taxonomy] => product_cat
        [description] => 
        [parent] => 16
        [count] => 0
        [filter] => raw
        [cat_ID] => 19
        [category_count] => 0
        [category_description] => 
        [cat_name] => Accessories
        [category_nicename] => accessories
        [category_parent] => 16
    )

[1] => WP_Term Object
    (
        [term_id] => 24
        [name] => Book
        [slug] => book
        [term_group] => 0
        [term_taxonomy_id] => 24
        [taxonomy] => category
        [description] => 
        [parent] => 0
        [count] => 0
        [filter] => raw
        [cat_ID] => 24
        [category_count] => 0
        [category_description] => 
        [cat_name] => Book
        [category_nicename] => book
        [category_parent] => 0
    )

使用此功能我可以获得 WordPress 分类 URL:

echo get_category_link(get_cat_ID($cat->slug)) ;

但为什么不返回第一个对象的 URL?

0 个答案:

没有答案
相关问题