Learn the difference between free and premium WordPress themes. Find out which one is right for your website with pros, cons, and tips.
How to Add Custom Fields to Taxonomies in WordPress (Complete Guide)

If you’re working with categories, tags, or custom taxonomies in WordPress, you might want to store extra information. You can do this by adding custom fields to your taxonomy terms. This guide will show you how, using both plugins and custom code.
Table of Contents
- What Are Taxonomies in WordPress?
- Why Add Custom Fields to Taxonomies?
- Method 1: Add Custom Fields Using a Plugin
- Method 2: Add Custom Fields with Code (ACF Alternative)
- How to Display Custom Fields on the Frontend
- Best Practices for Using Custom Taxonomy Fields
- Conclusion
- FAQs
What Are Taxonomies in WordPress?
Taxonomies are used to group content. The most common ones are:
- Categories
- Tags
You can also create custom taxonomies to organize content your own way. For example, you might add a “Genre” taxonomy for books or “Location” for real estate listings.
Why Add Custom Fields to Taxonomies?
Custom fields let you:
- Add extra details like images, descriptions, or metadata.
- Show unique content on archive pages.
- Control design or display using custom logic.
Example: You could add a “Banner Image” field to a category and show it on category archive pages.
Method 1: Add Custom Fields Using a Plugin
The easiest way is to use a plugin. Here’s how with Advanced Custom Fields (ACF):
Step-by-step:
- Install and activate the ACF plugin.
- Go to Custom Fields > Add New.
- Add a field group and click Add Field.
- Set the field label (e.g., “Category Icon”).
- Under Location Rules, set it to:
- Show this field group if Taxonomy Term is equal to your desired taxonomy (like Category).
- Save and go to your taxonomy edit screen to see the field.
- You can now fill out this field for each term.
Method 2: Add Custom Fields with Code (ACF Alternative)
You can also add custom fields without a plugin.
Example: Add a field to a taxonomy
// Add custom field to taxonomy edit form
add_action('category_add_form_fields', 'add_category_custom_field');
add_action('category_edit_form_fields', 'edit_category_custom_field');
function add_category_custom_field() {
?>
<div class="form-field">
<label for="term_meta[subtitle]">Subtitle</label>
<input type="text" name="term_meta[subtitle]" id="term_meta[subtitle]" />
</div>
<?php
}
function edit_category_custom_field($term) {
$term_id = $term->term_id;
$term_meta = get_option("taxonomy_$term_id");
?>
<tr class="form-field">
<th><label for="term_meta[subtitle]">Subtitle</label></th>
<td>
<input type="text" name="term_meta[subtitle]" value="<?php echo esc_attr($term_meta['subtitle']); ?>" />
</td>
</tr>
<?php
}
// Save custom field
add_action('edited_category', 'save_category_custom_field');
add_action('create_category', 'save_category_custom_field');
function save_category_custom_field($term_id) {
if (isset($_POST['term_meta'])) {
update_option("taxonomy_$term_id", $_POST['term_meta']);
}
}
How to Display Custom Fields on the Frontend
To show the field on a category archive or post, use:
$term_id = get_queried_object()->term_id;
$term_meta = get_option("taxonomy_$term_id");
echo esc_html($term_meta['subtitle']);
Or if you’re using ACF:
$term_id = get_queried_object_id();
echo get_field('your_field_name', 'category_' . $term_id);
Best Practices for Using Custom Taxonomy Fields
- Use ACF for easier management unless you’re building a custom plugin.
- Keep your code modular if adding many fields.
- Always escape and validate user inputs.
- Use get_queried_object() for archive pages.
Conclusion
Adding custom fields to taxonomies in WordPress opens up a world of possibilities for organizing and displaying your content. Whether you use a plugin like ACF or write your own code, the process is flexible and powerful.
FAQs
Can I add custom fields to tags or custom taxonomies?
Yes! Just update the code or plugin settings to target the specific taxonomy.
Is ACF the only plugin that works?
No. You can also use plugins like Meta Box or Pods.
Will these fields show up on the frontend automatically?
No. You need to edit your theme files to display them.
Can I use these fields in a theme builder like Elementor?
Yes, many page builders support ACF fields or custom meta fields.
This Post Has 0 Comments