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

Try the get_terms function

$terms = get_terms('link_category');

In the source code for Wordpress 3.3.1 get_bookmarks() function, the link category is acquired like this:

$_bookmark->link_category = array_unique( wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')) );

What version of WordPress are you using? If it isn't getting the link_category, you may be able to manually get it the way the get_bookmarks() function does.