Using WordPress ‘edit_bookmark_link()’ PHP function

The edit_bookmark_link() WordPress PHP function is used to display the edit bookmark link anchor content.

Usage

edit_bookmark_link('Edit Bookmark', '<div>', '</div>', 123);

In this example, ‘Edit Bookmark’ is the anchor text. The link is wrapped within a div element. The bookmark with ID 123 is set to be edited.

Parameters

  • $link (string – Optional) – Anchor text. If empty, default is ‘Edit This’. Default: ”
  • $before (string – Optional) – Display before edit link. Default: ”
  • $after (string – Optional) – Display after edit link. Default: ”
  • $bookmark (int – Optional) – Bookmark ID. Default is the current bookmark. Default: null

More information

See WordPress Developer Resources: edit_bookmark_link

This function was implemented in WordPress 2.7.0. The source code for this function can be found in wp-includes/link-template.php.

Examples

edit_bookmark_link();

This will display the default ‘Edit This’ link for the current bookmark.

Setting custom anchor text

edit_bookmark_link('Edit Bookmark');

Here, ‘Edit Bookmark’ will be displayed as the anchor text instead of the default ‘Edit This’.

edit_bookmark_link('Edit Bookmark', '<div>', '</div>');

The ‘Edit Bookmark’ link will be wrapped within a div element.

Editing a specific bookmark

edit_bookmark_link('Edit Bookmark', '<div>', '</div>', 123);

This will display the ‘Edit Bookmark’ link for the bookmark with ID 123. The link is wrapped within a div element.

No anchor text, just HTML

edit_bookmark_link('', '<div>', '</div>');

This will display the default ‘Edit This’ link, wrapped within a div element, for the current bookmark.

Tagged in

Leave a Comment

Your email address will not be published. Required fields are marked *