On this page
get_bookmark_field( string $field, int $bookmark, string $context = 'display' ): string|WP_Error
Retrieves single bookmark data item or field.
Parameters
$fieldstring Required-
The name of the data field to return.
$bookmarkint Required-
The bookmark ID to get field.
$contextstring Optional-
The context of how the field will be used.
Default:
'display'
Return
string|WP_Error
Source
File: wp-includes/bookmark.php. View all references
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 );
}
Related
Uses
| Uses | Description |
|---|---|
| sanitize_bookmark_field() wp-includes/bookmark.php | Sanitizes a bookmark field. |
| get_bookmark() wp-includes/bookmark.php | Retrieves bookmark data. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_bookmark_field