0

I know how to get a bookmark in wordpress by the bookmark id.

<?php $bookmark = get_bookmark(8); ?>
<a href="<?php echo $bookmark->link_url; ?>" target="_new">link</a>

How can I get it by its name instead of its id?

Thank you.

francadaval
  • 2,451
  • 3
  • 26
  • 36

2 Answers2

1

Well apart from using the $wpdb with an SQL-query directly you could use the search-option of get_bookmarks:

$bookmarks = get_bookmarks(array('search' => 'link_name name'));

But it searches not only the link_name field but also other fields:

Searches link_url, link_name or link_description like the search string

vstm
  • 12,407
  • 1
  • 51
  • 47
1
           <?php 

           $links = get_bookmarks( array('category' => "136"));
            foreach ( $links as $link ) {
            $linkname = $link->link_name;
            if ( substr($linkname, 0, 1) == "C"){
            echo '<ul><li><a title="'.$link->link_description.'" href="'.$link->link_url.'" target="_blank"></li></ul>';
            echo $link->link_name.'</a> <br/> ';}
            }

           ?>