get_bookmark_field()
Retrieves single bookmark data item or field.
No Hooks.
Returns
String|WP_Error.
Usage
get_bookmark_field( $field, $bookmark, $context );
- $field(string) (required)
- The name of the data field to return.
- $bookmark(int) (required)
- The bookmark ID to get field.
- $context(string)
- The context of how the field will be used.
Default:'display'
Changelog
| Since 2.3.0 | Introduced. |
get_bookmark_field() get bookmark field code WP 6.9.1
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 );
}