The get_edit_tag_link WordPress PHP filter allows you to modify the edit link for a tag (or term in another taxonomy).
Usage
add_filter('get_edit_tag_link', 'your_custom_function', 10, 1); function your_custom_function($link) { // your custom code here return $link; }
Parameters
- $link (string): The term edit link that you want to modify.
More information
See WordPress Developer Resources: get_edit_tag_link
Examples
Add a custom query parameter to the tag edit link
This example adds a custom query parameter named source
with a value of example
to the tag edit link.
add_filter('get_edit_tag_link', 'add_custom_query_param', 10, 1); function add_custom_query_param($link) { $link = add_query_arg('source', 'example', $link); return $link; }
Change the edit tag link to a custom admin page
This example changes the edit tag link to a custom admin page with the slug my_custom_page
.
add_filter('get_edit_tag_link', 'change_to_custom_admin_page', 10, 1); function change_to_custom_admin_page($link) { $link = admin_url('admin.php?page=my_custom_page'); return $link; }
Append a custom HTML element to the edit link
This example appends a custom HTML element (an icon) to the tag edit link.
add_filter('get_edit_tag_link', 'append_custom_html_element', 10, 1); function append_custom_html_element($link) { $link .= ' <i class="fas fa-edit"></i>'; return $link; }
Add a CSS class to the edit tag link
This example adds a CSS class called custom_class
to the edit tag link.
add_filter('get_edit_tag_link', 'add_css_class', 10, 1); function add_css_class($link) { $link = str_replace('<a ', '<a class="custom_class" ', $link); return $link; }
Redirect the edit tag link to the frontend
This example changes the edit tag link to redirect to a frontend page with a custom URL structure /tag/{tag_id}/edit
.
add_filter('get_edit_tag_link', 'frontend_edit_tag_link', 10, 1); function frontend_edit_tag_link($link) { if (preg_match('/tag_ID=(\d+)/', $link, $matches)) { $tag_id = $matches[1]; $link = home_url("/tag/{$tag_id}/edit"); } return $link; }