Using WordPress ‘edit_tag_link()’ PHP function

The edit_tag_link() WordPress PHP function displays or retrieves the edit link for a tag with formatting.

Usage

Here’s a generic example of how to use the function:

edit_tag_link('Edit Tag', '<p>', '</p>', $tag);

In this example, ‘Edit Tag’ is the anchor text, ‘

‘ and ‘

‘ are the HTML elements before and after the link respectively, and $tag is the term object.

Parameters

  • $link (string) Optional: This is the anchor text. If empty, default is ‘Edit This’. Default: ''
  • $before (string) Optional: This is displayed before the edit link. Default: ''
  • $after (string) Optional: This is displayed after the edit link. Default: ''
  • $tag (WP_Term) Optional: This is the term object. If null, the queried object will be inspected. Default: null

More information

See WordPress Developer Resources: edit_tag_link()
Note: This function is included in WordPress since version 2.7.0.

Examples

Default Usage

This example will display the edit tag link with the default settings.

edit_tag_link();

This example will display the edit tag link with custom link text “Edit Tag”.

edit_tag_link('Edit Tag');

With HTML Tags

This example will display the edit tag link with custom link text “Edit Tag” within a paragraph <p> tag.

edit_tag_link('Edit Tag', '<p>', '</p>');

With Specific Tag

This example will display the edit tag link for a specific tag object $tag.

edit_tag_link('Edit Tag', '<p>', '</p>', $tag);

This example will display the edit tag link with default link text “Edit This” within a div <div> tag for a specific tag object $tag.

edit_tag_link('', '<div>', '</div>', $tag);