WordPress edit_bookmark_link() Function

Beginner
6 min read
Updated: Nov 2026
3 examples
Prints a link

Definition

In WordPress, edit_bookmark_link() prints a link that opens the edit screen for one bookmark. A bookmark is an entry in the old Links Manager, a list of links such as a blogroll.

The link only appears when the current user is allowed to manage links (the manage_links capability). Visitors see nothing. Newer sites hide the Links Manager by default, so you may need the Link Manager plugin to try this function.

Syntax

Call it inside a loop that shows bookmarks. Pass the bookmark object as the fourth argument.

WordPress
<?php edit_bookmark_link( 'Edit', '', '', $bookmark ); ?>
CallWhat it does
edit_bookmark_link( 'Edit', '', '', $bookmark )Print an Edit link for one bookmark.
edit_bookmark_link( 'Edit', '<span>', '</span>', $bookmark )Wrap the link in your own HTML.
edit_bookmark_link()Use the default link text. It works when WordPress already knows the current bookmark.

The function prints the link. It does not return it, so do not use echo in front of it.

Full declaration
WordPress
edit_bookmark_link( string $link = '', string $before = '', string $after = '', int|stdClass $bookmark = null ): void

Parameters

ParameterDescription
$linkstring. The text of the link. If empty, WordPress uses its default text (Edit This).
$beforestring. HTML printed before the link. Default is an empty string.
$afterstring. HTML printed after the link. Default is an empty string.
$bookmarkint|stdClass. A bookmark ID or a bookmark object, for example one item from get_bookmarks().

Return Value

Return ValueDescription
voidNothing is returned. The link is printed. If the user cannot manage links, nothing is printed.

WordPress Examples

Three short examples. Each one shows the code and what it prints or does.

Example 1 — Add an edit link to a bookmark list

Loop over your bookmarks and show an edit link next to each one.

WordPress
<?php
$bookmarks = get_bookmarks();
foreach ( $bookmarks as $bookmark ) {
  echo '<li><a href="' . esc_url( $bookmark->link_url ) . '">' . esc_html( $bookmark->link_name ) . '</a> ';
  edit_bookmark_link( 'Edit', '', '', $bookmark );
  echo '</li>';
}

How It Works

  1. get_bookmarks() returns the saved links.
  2. For each one we print the normal link.
  3. edit_bookmark_link() adds the Edit link for an administrator or editor.

Example 2 — Wrap the link with before and after

Use $before and $after to add a small wrapper only when the link is shown.

WordPress
<?php
edit_bookmark_link( 'Edit this link', '<p class="edit-row">', '</p>', $bookmark );

How It Works

  1. The first text is the link label.
  2. The second and third values wrap the link.
  3. A visitor who cannot edit links sees no p tag at all.

Example 3 — Pass a bookmark ID

You can also pass a bookmark ID instead of an object.

WordPress
<?php
// Edit link for the bookmark with ID 5.
edit_bookmark_link( 'Change this link', '[ ', ' ]', 5 );

How It Works

  1. 5 is the bookmark ID.
  2. WordPress builds the edit URL for that bookmark.
  3. The square brackets only print when the link prints.

Frequently Asked Questions

It prints a link to the edit screen of one bookmark. The link shows only to users who can manage links.
Either you are not logged in as a user who can manage links, or the Links Manager is turned off. New sites hide it unless the Link Manager plugin is active.
No. It prints the link and returns nothing. To get only the URL, use get_edit_bookmark_link().
Yes, if you pass a bookmark ID or object as the fourth argument.
Yes. Visitors without permission get no output, so there is no broken link.

Next: edit_comment_link()

Print an edit link for the current comment if the user can edit it.

edit_comment_link() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful