Title: wp_update_link
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_update_link( array $linkdata ): int|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#wp--skip-link--target)

Updates a link in the database.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#parameters)󠁿

 `$linkdata`arrayrequired

Link data to update. See [wp_insert_link()](https://developer.wordpress.org/reference/functions/wp_insert_link/)
for accepted arguments.

More Arguments from wp_insert_link( … $linkdata )

Elements that make up the link to insert.

 * `link_id` int
 * Optional. The ID of the existing link if updating.
 * `link_url` string
 * The URL the link points to.
 * `link_name` string
 * The title of the link.
 * `link_image` string
 * Optional. A URL of an image.
 * `link_target` string
 * Optional. The target element for the anchor tag.
 * `link_description` string
 * Optional. A short description of the link.
 * `link_visible` string
 * Optional. `'Y'` means visible, anything else means not.
 * `link_owner` int
 * Optional. A user ID.
 * `link_rating` int
 * Optional. A rating for the link.
 * `link_rel` string
 * Optional. A relationship of the link to you.
 * `link_notes` string
 * Optional. An extended description of or notes on the link.
 * `link_rss` string
 * Optional. A URL of an associated RSS feed.
 * `link_category` int
 * Optional. The term ID of the link category.
    If empty, uses default link category.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#return)󠁿

 int|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) Value
0 or [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) on 
failure. The updated link ID on success.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#source)󠁿

    ```php
    function wp_update_link( $linkdata ) {
    	$link_id = (int) $linkdata['link_id'];

    	$link = get_bookmark( $link_id, ARRAY_A );

    	// Escape data pulled from DB.
    	$link = wp_slash( $link );

    	// Passed link category list overwrites existing category list if not empty.
    	if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )
    		&& count( $linkdata['link_category'] ) > 0
    	) {
    		$link_cats = $linkdata['link_category'];
    	} else {
    		$link_cats = $link['link_category'];
    	}

    	// Merge old and new fields with new fields overwriting old ones.
    	$linkdata                  = array_merge( $link, $linkdata );
    	$linkdata['link_category'] = $link_cats;

    	return wp_insert_link( $linkdata );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/bookmark.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/bookmark.php#L300)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/bookmark.php#L300-L322)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_insert_link()](https://developer.wordpress.org/reference/functions/wp_insert_link/)`wp-admin/includes/bookmark.php` |

Inserts a link into the database, or updates an existing link.

  | 
| [get_bookmark()](https://developer.wordpress.org/reference/functions/get_bookmark/)`wp-includes/bookmark.php` |

Retrieves bookmark data.

  | 
| [wp_slash()](https://developer.wordpress.org/reference/functions/wp_slash/)`wp-includes/formatting.php` |

Adds slashes to a string or recursively adds slashes to strings within an array.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#)

| Used by | Description | 
| [edit_link()](https://developer.wordpress.org/reference/functions/edit_link/)`wp-admin/includes/bookmark.php` |

Updates or inserts a link using values provided in $_POST.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_update_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.0.0](https://developer.wordpress.org/reference/since/2.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_update_link%2F)
before being able to contribute a note or feedback.