Using WordPress ‘get_bookmark_field()’ PHP function

The get_bookmark_field() WordPress PHP function retrieves a single bookmark data item or field.

Usage

echo get_bookmark_field('field_name', $bookmark_id, 'context');

Parameters

  • $field (string) – The name of the data field to return.
  • $bookmark (int) – The bookmark ID to get the field.
  • $context (string) – Optional. The context of how the field will be used. Default is ‘display’.

More information

See WordPress Developer Resources: get_bookmark_field()

Examples

Get bookmark name

Retrieve the name of a bookmark with ID 42.

$bookmark_id = 42;
$bookmark_name = get_bookmark_field('name', $bookmark_id);
echo "Bookmark name: " . $bookmark_name;

Get bookmark URL

Retrieve the URL of a bookmark with ID 42.

$bookmark_id = 42;
$bookmark_url = get_bookmark_field('url', $bookmark_id);
echo "Bookmark URL: " . $bookmark_url;

Get bookmark description

Retrieve the description of a bookmark with ID 42.

$bookmark_id = 42;
$bookmark_description = get_bookmark_field('description', $bookmark_id);
echo "Bookmark description: " . $bookmark_description;

Get bookmark target

Retrieve the target of a bookmark with ID 42.

$bookmark_id = 42;
$bookmark_target = get_bookmark_field('target', $bookmark_id);
echo "Bookmark target: " . $bookmark_target;

Get bookmark category

Retrieve the category of a bookmark with ID 42.

$bookmark_id = 42;
$bookmark_category = get_bookmark_field('category', $bookmark_id);
echo "Bookmark category: " . $bookmark_category;

Tagged in

Leave a Comment

Your email address will not be published. Required fields are marked *