• Hi,

    So I’m using the bookmarks section of WP as a kind of pseudo CMS for entering small data. Each item has a title (the name) a text field (the bookmark’s note) and a category (the bookmarks category).

    I’ve been trying for ages, but cant seem to write a function that does the following.

    – Lists all my bookmarks by category
    – Lists each of these bookmarks in a way that displays both the title and the ‘notes’ field (ie echo $bookmark->link_name; and echo $bookmark->link_notes; )

    ie

    CAT1
    BOOMARKTITLE1
    BOOKMARKNOTE1
    BOOMARKTITLE2
    BOOKMARKNOTE2
    BOOMARKTITLE3
    BOOKMARKNOTE3

    CAT2
    BOOMARKTITLE1
    BOOKMARKNOTE1
    BOOMARKTITLE2
    BOOKMARKNOTE2
    CAT3
    ….

    Anybody have any thoughts? Would be much appreciated

Viewing 3 replies - 1 through 3 (of 3 total)
  • <?php wp_list_bookmarks('categorize=1&show_name=1&show_description=1'); ?>

    That doesn’t work for you?

    Thread Starter ulterior

    (@ulterior)

    No it doesnt, I need to display the notes field of each link, not the description

    Ah – I see. Well, looking at the bookmark.php file (in includes) there’s a function you might be able to use:

    get_bookmark_field( $field, $bookmark, $context = 'display' );

    Nothing in the codex on it that I can find. But there’s also get_bookmark( $bookmark, $output, $filter );, and that might be more helpful. I’d say you could write a function that creates its own loop, and uses the above to output the bookmarks in array format, and pull the contents of the link_notes field.

    So, for example (and this is totally untested and off the top of my head, but it might be a start):

    function custom_bookmarks() {
      global $wpdb;
      $bookmarks = get_bookmarks();
    
      if($bookmarks) {
        foreach($bookmarks as $bm) {
          $id = $bm->link_id;
          $add = get_bookmark($id);
          $notes = $add->link_notes;
    
          $link .= '<li><a href="' . $bm->link_url . '">' . $bm->link_name . '</a><br />' . $notes . '</li>';
        }
      }
      echo $links;
    }

    Maybe that would do it?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Weird Request: Get bookmarks under categories displaying notes’ is closed to new replies.