get_bookmark_field

Retrieve single bookmark data item or field.

Description

(string|WP_Error) get_bookmark_field( (string) $field, (int) $bookmark, (string) $context = 'display' ); 

Returns (string|WP_Error)

Parameters (3)

0. $field (string)
The name of the data field to return
1. $bookmark (int)
The bookmark ID to get field
2. $context — Optional. (string) => 'display'
The context of how the field will be used.

Usage

  1. if ( !function_exists( 'get_bookmark_field' ) ) { 
  2. require_once ABSPATH . WPINC . '/bookmark.php'; 
  3.  
  4. // The name of the data field to return 
  5. $field = ''; 
  6.  
  7. // The bookmark ID to get field 
  8. $bookmark = -1; 
  9.  
  10. // Optional. The context of how the field will be used. 
  11. $context = 'display'; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = get_bookmark_field($field, $bookmark, $context); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/bookmark.php  
  1. function get_bookmark_field( $field, $bookmark, $context = 'display' ) { 
  2. $bookmark = (int) $bookmark; 
  3. $bookmark = get_bookmark( $bookmark ); 
  4.  
  5. if ( is_wp_error($bookmark) ) 
  6. return $bookmark; 
  7.  
  8. if ( !is_object($bookmark) ) 
  9. return ''; 
  10.  
  11. if ( !isset($bookmark->$field) ) 
  12. return ''; 
  13.  
  14. return sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context);