The edit_tag_form_fields WordPress PHP action fires after the Edit Tag form fields are displayed, allowing you to add or modify the form fields.
Usage
add_action('edit_tag_form_fields', 'your_custom_function', 10, 1);
function your_custom_function($tag) {
// Your custom code here
}
Parameters
$tag(WP_Term): The current tag term object.
More information
See WordPress Developer Resources: edit_tag_form_fields
Examples
Adding a custom field to the Edit Tag form
This example adds a custom field to the Edit Tag form to store additional information about the tag.
add_action('edit_tag_form_fields', 'add_custom_field_to_edit_tag', 10, 1);
function add_custom_field_to_edit_tag($tag) {
$term_meta = get_term_meta($tag->term_id, 'custom_field', true);
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="custom_field">Custom Field</label></th>
<td>
<input type="text" name="custom_field" id="custom_field" value="<?php echo esc_attr($term_meta); ?>">
<p class="description">Enter a custom value for this tag.</p>
</td>
</tr>
<?php
}
Adding a checkbox field to the Edit Tag form
This example adds a custom checkbox field to the Edit Tag form.
add_action('edit_tag_form_fields', 'add_custom_checkbox_to_edit_tag', 10, 1);
function add_custom_checkbox_to_edit_tag($tag) {
$term_meta = get_term_meta($tag->term_id, 'custom_checkbox', true);
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="custom_checkbox">Custom Checkbox</label></th>
<td>
<input type="checkbox" name="custom_checkbox" id="custom_checkbox" <?php checked($term_meta, '1'); ?>>
<span class="description">Check this box for custom functionality.</span>
</td>
</tr>
<?php
}