Support » Themes and Templates » get_bookmarks returns wrong link_category

  • MephistoBS

    (@mephistobs)


    The links in my blogroll are partitioned into a couple of link categories. I’ve tried to use get_bookmarks() to get a list of all links in my blogroll together with the link category (which is the value I’m searching for).

    $links = get_bookmarks();
    foreach( $links as $link ) {
      if ( $link->link_url == $reference ) {
        $catFound = $link->link_category;
        break;
      }
    }

    However, the get_bookmarks function returns a list of all my links but the values in the link_category fields are not those, which I expected (I expected the IDs which are used by the link-manager (cat_id=#). Not only that, some links which are in different link categories (in the link manager) get the same ID in get_bookmarks and other links in the same link category get different categories.

    WordPress Version 2.7

    Is my expection that the link_category value from get_bookmarks should be the same as in the link manager wrong?

    Ciao, Meph

Viewing 1 replies (of 1 total)
  • MephistoBS

    (@mephistobs)

    It seems that get_bookmarks returns and old (?) value from the wp_links table. The real link category is stored in the taxonomy system introducted some releases earlier. Using the link_id value, the link category ID can be obtained like this:

    $catID = $wpdb->get_var( "SELECT t.term_id FROM $wpdb->term_taxonomy t, $wpdb->term_relationships r WHERE t.taxonomy='link_category' AND t.term_taxonomy_id=r.term_taxonomy_id AND object_id=" . $link->link_id );

    Anyway, my expections regarding the get_bookmarks function are that it should return the category ID from the taxonomy system and not the old/unused (?) value from the wp_links table.

    Ciao, Meph

Viewing 1 replies (of 1 total)
  • The topic ‘get_bookmarks returns wrong link_category’ is closed to new replies.