Using WordPress ‘edit_tag_form_pre’ PHP action

The edit_tag_form_pre WordPress PHP action fires before the Edit Tag form is displayed, allowing you to perform custom actions or modifications.


add_action('edit_tag_form_pre', 'your_custom_function');
function your_custom_function($tag) {
  // your custom code here


  • $tag (WP_Term) – The current tag term object.

More information

See WordPress Developer Resources: edit_tag_form_pre


Add a custom message before the Edit Tag form

Display a custom message before the Edit Tag form to provide additional information to users.

add_action('edit_tag_form_pre', 'add_custom_message');
function add_custom_message($tag) {
  echo '<p><strong>Note:</strong> Please make sure to follow our guidelines when editing tags.</p>';

Change the tag description before display

Modify the tag description before the Edit Tag form is displayed to the user.

add_action('edit_tag_form_pre', 'modify_tag_description');
function modify_tag_description($tag) {
  $tag->description .= ' (modified)';

Add custom CSS to the Edit Tag form

Add custom CSS to style the Edit Tag form differently.

add_action('edit_tag_form_pre', 'add_custom_css');
function add_custom_css($tag) {
  echo '<style>.form-wrap { background-color: #f1f1f1; }</style>';

Hide a specific tag from the Edit Tag form

Prevent a specific tag from being edited by hiding it from the Edit Tag form.

add_action('edit_tag_form_pre', 'hide_specific_tag');
function hide_specific_tag($tag) {
  if ($tag->term_id == 5) {

Log tag edit events

Track when users access the Edit Tag form to edit tags.

add_action('edit_tag_form_pre', 'log_tag_edits');
function log_tag_edits($tag) {
  error_log('User ' . get_current_user_id() . ' accessed the Edit Tag form for tag: ' . $tag->name);