get_bookmark()
Gets the link data from the blogroll, in the form of an array. You need to specify the link ID.
No Hooks.
Returns
Array|Object|null.
Usage
<?php get_bookmark( $bookmark, $output, $filter ) ?>
- $bookmark(number) (required)
- Link ID from the blogroll (admin -> links -> links).
- $output(string)
- In what format to return the result. Can be:
OBJECT— as an object;
ARRAY_N— as a numeric array;
ARRAY_A— as an associative array.
Default: OBJECT - $filter(string)
- Filter (???).
Default: 'raw'
Examples
#1 Basic Example
Let's get the data of bookmark 13 and display its URL:
<?php $link = get_bookmark( 13, ARRAY_N ); echo $link->link_url; ?>
In this example, the $link variable will contain the following object:
stdClass Object ( [link_id] => 13 [link_url] => http://www.gogetlinks.net/?inv=n98gxr [link_name] => gogetlinks.net [link_image] => http://wp-kama.com/wp-includes/images/crystal/archive.png [link_target] => [link_description] => Buy/sell quality links, forever [link_visible] => Y [link_owner] => 1 [link_rating] => 0 [link_updated] => 0000-00-00 00:00:00 [link_rel] => [link_notes] => [link_rss] => [link_category] => Array() )
#2 Display Bookmark Name
<?php $bookmark = get_bookmark(5); echo $bookmark->link_name; ?>
or:
<?php echo get_bookmark(5)->link_name; ?>
#3 Display Bookmark as a Link
<?php $bookmark = get_bookmark( 5 ); echo '<a href="'. $bookmark->link_url .'">'. $bookmark->link_name .'</a>'; ?>
Notes
- Global. Object.
$linkCurrent link object. - Global. wpdb.
$wpdbWordPress database abstraction object.
Changelog
| Since 2.1.0 | Introduced. |