wp_delete_link

Deletes a specified link from the database.

Description

wp_delete_link( (int) $link_id ); 

Parameters (1)

0. $link_id (int)
ID of the link to delete

Usage

  1. if ( !function_exists( 'wp_delete_link' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/bookmark.php'; 
  3.  
  4. // ID of the link to delete 
  5. $link_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_delete_link($link_id); 
  9.  

Defined (1)

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

/wp-admin/includes/bookmark.php  
  1. function wp_delete_link( $link_id ) { 
  2. global $wpdb; 
  3. /** 
  4. * Fires before a link is deleted. 
  5. * @since 2.0.0 
  6. * @param int $link_id ID of the link to delete. 
  7. */ 
  8. do_action( 'delete_link', $link_id ); 
  9.  
  10. wp_delete_object_term_relationships( $link_id, 'link_category' ); 
  11.  
  12. $wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) ); 
  13.  
  14. /** 
  15. * Fires after a link has been deleted. 
  16. * @since 2.2.0 
  17. * @param int $link_id ID of the deleted link. 
  18. */ 
  19. do_action( 'deleted_link', $link_id ); 
  20.  
  21. clean_bookmark_cache( $link_id ); 
  22.  
  23. return true;