Using WordPress ‘get_edit_bookmark_link()’ PHP function

The get_edit_bookmark_link() WordPress PHP function displays the edit bookmark link.

Usage

echo get_edit_bookmark_link( $bookmark_id );

Example:
Input:

echo get_edit_bookmark_link( 42 );

Output:

https://example.com/wp-admin/link.php?action=edit&link_id=42

Parameters

  • $bookmark_id (int|stdClass) (Optional) Bookmark ID. Default is the ID of the current bookmark.

More information

See WordPress Developer Resources: get_edit_bookmark_link()

Examples

Display the edit link for the bookmark with an ID of 10.

$bookmark_id = 10;
echo get_edit_bookmark_link( $bookmark_id );

Display the edit link for the current bookmark within a loop of bookmarks.

// Get an array of bookmarks
$bookmarks = get_bookmarks();

// Loop through the bookmarks and display the edit link for each
foreach ( $bookmarks as $bookmark ) {
    echo get_edit_bookmark_link( $bookmark->link_id );
}

Add the edit bookmark link to a custom HTML structure for better styling.

$bookmark_id = 15;
$edit_link = get_edit_bookmark_link( $bookmark_id );
echo '<div class="edit-bookmark-link"><a href="' . esc_url( $edit_link ) . '">Edit Bookmark</a></div>';

Only show the edit bookmark link if the user is logged in and has permission to edit bookmarks.

$bookmark_id = 20;
if ( current_user_can( 'manage_links' ) ) {
    echo get_edit_bookmark_link( $bookmark_id );
}

Display the edit bookmark link with custom text instead of the default “Edit This”.

$bookmark_id = 25;
$edit_link = get_edit_bookmark_link( $bookmark_id );
echo '<a href="' . esc_url( $edit_link ) . '">Edit this Bookmark</a>';