Title: edit_term_link
Published: April 25, 2014
Last modified: February 24, 2026

---

# edit_term_link( string $link, string $before, string $after, int|WP_Term|null $term = null, bool $display = true ): string|void

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#wp--skip-link--target)

Displays or retrieves the edit term link with formatting.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#parameters)󠁿

 `$link`stringoptional

Anchor text. If empty, default is ‘Edit This’. Default empty.

`$before`stringoptional

Display before edit link. Default empty.

`$after`stringoptional

Display after edit link. Default empty.

`$term`int|[WP_Term](https://developer.wordpress.org/reference/classes/wp_term/)
|nulloptional

Term ID or object. If null, the queried object will be inspected.

Default:`null`

`$display`booloptional

Whether or not to echo the return.

Default:`true`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#return)󠁿

 string|void HTML content.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#source)󠁿

    ```php
    function edit_term_link( $link = '', $before = '', $after = '', $term = null, $display = true ) {
    	if ( is_null( $term ) ) {
    		$term = get_queried_object();
    	} else {
    		$term = get_term( $term );
    	}

    	if ( ! $term ) {
    		return;
    	}

    	$tax = get_taxonomy( $term->taxonomy );
    	if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
    		return;
    	}

    	if ( empty( $link ) ) {
    		$link = __( 'Edit This' );
    	}

    	$link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>';

    	/**
    	 * Filters the anchor tag for the edit link of a term.
    	 *
    	 * @since 3.1.0
    	 *
    	 * @param string $link    The anchor tag for the edit link.
    	 * @param int    $term_id Term ID.
    	 */
    	$link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after;

    	if ( $display ) {
    		echo $link;
    	} else {
    		return $link;
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/link-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/link-template.php#L1136)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/link-template.php#L1136-L1173)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#hooks)󠁿

 [apply_filters( ‘edit_term_link’, string $link, int $term_id )](https://developer.wordpress.org/reference/hooks/edit_term_link/)

Filters the anchor tag for the edit link of a term.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#related)󠁿

| Uses | Description | 
| [get_queried_object()](https://developer.wordpress.org/reference/functions/get_queried_object/)`wp-includes/query.php` |

Retrieves the currently queried object.

  | 
| [get_edit_term_link()](https://developer.wordpress.org/reference/functions/get_edit_term_link/)`wp-includes/link-template.php` |

Retrieves the URL for editing a given term.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [get_term()](https://developer.wordpress.org/reference/functions/get_term/)`wp-includes/taxonomy.php` |

Gets all term data from database by term ID.

  | 
| [get_taxonomy()](https://developer.wordpress.org/reference/functions/get_taxonomy/)`wp-includes/taxonomy.php` |

Retrieves the taxonomy object of $taxonomy.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#)

| Used by | Description | 
| [edit_tag_link()](https://developer.wordpress.org/reference/functions/edit_tag_link/)`wp-includes/link-template.php` |

Displays or retrieves the edit link for a tag with formatting.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/edit_term_link/?output_format=md#comment-content-1623)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/edit_term_link/#comment-1623)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fedit_term_link%2F%23comment-1623)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fedit_term_link%2F%23comment-1623)
 4. **Display link to edit term**
 5.     ```php
        $term = get_term_by( 'slug', 'uncategorized', 'category' );
        edit_term_link( __( 'Edit', 'textdomain' ), '<span class="edit-term">', '</span>', $term );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fedit_term_link%2F%3Freplytocom%3D1623%23feedback-editor-1623)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fedit_term_link%2F)
before being able to contribute a note or feedback.