The get_bookmark() WordPress PHP function retrieves bookmark data.
Usage
get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
Example:
$bookmark = get_bookmark(5, ARRAY_A); echo $bookmark['link_name'];
Parameters
$bookmark (int|stdClass) (Required)
– The ID of the bookmark or a bookmark object.$output (string) (Optional)
– The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to an stdClass object, an associative array, or a numeric array, respectively. Default: OBJECT.$filter (string) (Optional)
– How to sanitize bookmark fields. Default ‘raw’. Default: ‘raw’.
More information
See WordPress Developer Resources: get_bookmark()
Examples
Display Bookmark Name
This example retrieves a bookmark with the ID of 5 and displays its name.
$bookmark = get_bookmark(5); echo $bookmark->link_name;
Display Bookmark Name (Alternative Method)
This example retrieves a bookmark with the ID of 5 and displays its name using an alternative method.
echo get_bookmark(5)->link_name;
Display Bookmark as a Link
This example retrieves a bookmark with the ID of 5 and displays it as a clickable link.
$bookmark = get_bookmark(5); echo '<a href="' . $bookmark->link_url . '">' . $bookmark->link_name . '</a>';
Get Bookmark Data as an Associative Array
This example retrieves a bookmark with the ID of 5 and returns its data as an associative array.
$bookmark = get_bookmark(5, ARRAY_A); print_r($bookmark);
Get Bookmark Data as a Numeric Array
This example retrieves a bookmark with the ID of 5 and returns its data as a numeric array.
$bookmark = get_bookmark(5, ARRAY_N); print_r($bookmark);