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.
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.
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
<?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/> ';}
}
?>