dto52236 2012-04-11 11:11
浏览 171
已采纳

get_bookmarks()对象不返回link_category

I'm trying to fetch all link-categories from the built in Wordpress linklist (or bookmarks if you will).

To do this, I simply stored all links in a variable like this:

<?php
    $lists = get_bookmarks();
    foreach($lists as $list) {
        $cats[] = $list->link_category;
    }
?>

To my surprise even var_dump'ing $cats gave me "String(0)", so I var_dump'ed out $lists instead, and it gave me this:

array(8) { [0]=> object(stdClass)#5126 (13) { ["link_id"]=> string(1) "1" ["link_url"]=> string(27) "http://codex.wordpress.org/" ["link_name"]=> string(13) "Documentation" ["link_image"]=> string(0) "" ["link_target"]=> string(0) "" ["link_description"]=> string(0) "" ["link_visible"]=> string(1) "Y" ["link_owner"]=> string(1) "1" ["link_rating"]=> string(1) "0" ["link_updated"]=> string(19) "0000-00-00 00:00:00" ["link_rel"]=> string(0) "" ["link_notes"]=> string(0) "" ["link_rss"]=> string(0) "" }

Now, codex.wordpress.org is a default link that comes with wordpress, it's in a category called "Linklist", and as you can see, the object contains everything about that link, EXCEPT the categoryname.

According to the codex this object should contain a field named "link_category", so I'm getting confused here.

Am I missing something? Is the function broke?

Regards

NINJA

  • 写回答

2条回答 默认 最新

  • douling8772 2012-04-11 12:36
    关注

    Try the get_terms function

    $terms = get_terms('link_category');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题