The add_tag_form WordPress PHP action fires at the end of the Add Tag form, allowing you to add custom fields or functionality.
Usage
add_action('add_tag_form', 'your_custom_function'); function your_custom_function($taxonomy) { // your custom code here }
Parameters
- $taxonomy (string): The taxonomy slug.
More information
See WordPress Developer Resources: add_tag_form
Examples
Adding a custom field to the Add Tag form
This example adds a custom input field to the Add Tag form.
add_action('add_tag_form', 'add_custom_field_to_tag_form'); function add_custom_field_to_tag_form($taxonomy) { echo '<div class="form-field">'; echo '<label for="custom-field">Custom Field</label>'; echo '<input type="text" id="custom-field" name="custom_field" />'; echo '</div>'; }
Displaying a checkbox in the Add Tag form
This example adds a checkbox to the Add Tag form.
add_action('add_tag_form', 'add_checkbox_to_tag_form'); function add_checkbox_to_tag_form($taxonomy) { echo '<div class="form-field">'; echo '<label for="custom-checkbox">Custom Checkbox</label>'; echo '<input type="checkbox" id="custom-checkbox" name="custom_checkbox" />'; echo '</div>'; }
Adding a description to the Add Tag form
This example adds a custom description field to the Add Tag form.
add_action('add_tag_form', 'add_description_to_tag_form'); function add_description_to_tag_form($taxonomy) { echo '<div class="form-field">'; echo '<label for="custom-description">Custom Description</label>'; echo '<textarea id="custom-description" name="custom_description"></textarea>'; echo '</div>'; }
Displaying a custom select box in the Add Tag form
This example adds a custom select box to the Add Tag form.
add_action('add_tag_form', 'add_select_box_to_tag_form'); function add_select_box_to_tag_form($taxonomy) { echo '<div class="form-field">'; echo '<label for="custom-select">Custom Select</label>'; echo '<select id="custom-select" name="custom_select">'; echo '<option value="option1">Option 1</option>'; echo '<option value="option2">Option 2</option>'; echo '</select>'; echo '</div>'; }
Displaying a custom message in the Add Tag form
This example adds a custom message to the Add Tag form.
add_action('add_tag_form', 'add_custom_message_to_tag_form'); function add_custom_message_to_tag_form($taxonomy) { echo '<div class="form-field">'; echo '<p>Custom Message: This is an example of a custom message in the Add Tag form.</p>'; echo '</div>'; }