The get_edit_tag_link() WordPress PHP function retrieves the edit link for a tag.
Usage
get_edit_tag_link( $tag, $taxonomy = 'post_tag' );
Parameters
$tag
(int|WP_Term|object) – The ID or term object whose edit link will be retrieved.$taxonomy
(string) – Optional. Taxonomy slug. Default ‘post_tag’.
More information
See WordPress Developer Resources: get_edit_tag_link()
Examples
Display Edit Link for a Tag
This example displays the edit link for a tag with ID 10.
$tag_id = 10; $edit_link = get_edit_tag_link( $tag_id ); echo '<a href="' . esc_url( $edit_link ) . '">Edit Tag</a>';
Display Edit Link for a Custom Taxonomy
This example displays the edit link for a tag with ID 15 in a custom taxonomy called ‘genre’.
$tag_id = 15; $taxonomy = 'genre'; $edit_link = get_edit_tag_link( $tag_id, $taxonomy ); echo '<a href="' . esc_url( $edit_link ) . '">Edit Genre</a>';
Display Edit Link for a Tag within the Loop
This example displays the edit link for the first tag of the current post within the loop.
$tags = get_the_tags(); if ( $tags ) { $first_tag = array_shift( $tags ); $edit_link = get_edit_tag_link( $first_tag->term_id ); echo '<a href="' . esc_url( $edit_link ) . '">Edit First Tag</a>'; }
Display Edit Link for a Tag using WP_Term Object
This example displays the edit link for a tag using a WP_Term object.
$tag_object = get_term( 20, 'post_tag' ); $edit_link = get_edit_tag_link( $tag_object ); echo '<a href="' . esc_url( $edit_link ) . '">Edit Tag</a>';
Display Edit Link for all Tags
This example displays the edit link for all tags.
$tags = get_terms( array( 'taxonomy' => 'post_tag', 'hide_empty' => false ) ); foreach ( $tags as $tag ) { $edit_link = get_edit_tag_link( $tag ); echo '<a href="' . esc_url( $edit_link ) . '">Edit ' . esc_html( $tag->name ) . '</a><br>'; }