get_bookmark_field( string $field, int $bookmark, string $context = ‘display’ ): string|WP_Error

In this article

Retrieves single bookmark data item or field.

Parameters

$fieldstringrequired
The name of the data field to return.
$bookmarkintrequired
The bookmark ID to get field.
$contextstringoptional
The context of how the field will be used. Default 'display'.

Default:'display'

Return

string|WP_Error

Source

function get_bookmark_field( $field, $bookmark, $context = 'display' ) {
	$bookmark = (int) $bookmark;
	$bookmark = get_bookmark( $bookmark );

	if ( is_wp_error( $bookmark ) ) {
		return $bookmark;
	}

	if ( ! is_object( $bookmark ) ) {
		return '';
	}

	if ( ! isset( $bookmark->$field ) ) {
		return '';
	}

	return sanitize_bookmark_field( $field, $bookmark->$field, $bookmark->link_id, $context );
}

Changelog

VersionDescription
2.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.