WordPress edit_tag_link() Function

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

Definition

In WordPress, edit_tag_link() prints an edit link for a post tag. The link opens that tag in the admin area.

Use it in a tag archive template, next to the tag title. If you do not pass a tag, WordPress uses the tag that is being shown. The link appears only for users who can edit tags.

Syntax

Call it on a tag archive page, or pass a tag.

WordPress
<?php edit_tag_link( 'Edit tag' ); ?>
CallWhat it does
edit_tag_link( 'Edit tag' )Print an edit link for the tag being viewed.
edit_tag_link( 'Edit', '<p>', '</p>' )Wrap the link in a paragraph.
edit_tag_link( 'Edit', '', '', 7 )Print the edit link for the tag with ID 7.

It prints the link. It only works for tags (the post_tag taxonomy).

Full declaration
WordPress
edit_tag_link( string $link = '', string $before = '', string $after = '', int|WP_Term $tag = null ): void

Parameters

ParameterDescription
$linkstring. The link text. If empty, WordPress uses its default text (Edit This).
$beforestring. HTML printed before the link.
$afterstring. HTML printed after the link.
$tagint|WP_Term. A tag ID or a term object. Default is null, which means the current tag.

Return Value

Return ValueDescription
voidNothing is returned. The link is printed only when the user can edit the tag.

WordPress Examples

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

Example 1 — Add an edit link to a tag archive

Show the tag name, then the edit link for admins.

WordPress
<?php
// tag.php
single_tag_title( '<h1>', '</h1>' );
edit_tag_link( 'Edit tag' );

How It Works

  1. single_tag_title() prints the tag name.
  2. edit_tag_link() finds the current tag by itself.
  3. Only a user who can edit tags sees the link.

Example 2 — Wrap the link with before and after

Add HTML around the link without printing empty markup for visitors.

WordPress
<?php
edit_tag_link( 'Edit', '<p class="tag-tools">', '</p>' );

How It Works

  1. The text is Edit.
  2. The paragraph prints only when the link prints.
  3. Visitors get clean HTML.

Example 3 — Pass a tag object

Use a tag you looked up yourself, even outside a tag archive.

WordPress
<?php
$tag = get_term_by( 'slug', 'tutorials', 'post_tag' );
if ( $tag ) {
  edit_tag_link( 'Edit the Tutorials tag', '', '', $tag );
}

How It Works

  1. get_term_by() finds the tag with the slug tutorials.
  2. We check that the tag exists.
  3. edit_tag_link() uses that tag instead of the current one.

Frequently Asked Questions

It prints a link to the admin screen where a post tag can be edited. Only users who can edit tags see it.
No. It is for tags only. For categories and other taxonomies use edit_term_link().
In tag.php or any template that shows a tag archive. You can also use it elsewhere if you pass a tag.
No. It prints a full link. To get only the URL use get_edit_tag_link().
The user may not be logged in, may lack permission, or the tag could not be found.

Next: get_admin_url()

Return the admin area URL for a site, with an optional path.

get_admin_url() 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.

14 people found this page helpful