As an experienced WordPress professional with over 15 years in the industry, I‘ve seen firsthand how custom taxonomies and fields can transform a site. I‘m excited to share everything I‘ve learned to help you implement these powerful features yourself!
Contents
An Introduction to Custom Taxonomies and Fields
Out of the box, WordPress gives you two main taxonomies – categories and tags. These allow you to categorize and group your content.
But for many sites, you need to go beyond these basics. Custom taxonomies allow you to create entirely new ways of organizing your posts that make sense for your content.
For example, an online store may want taxonomies for brands, product types, colors, etc. A magazine could have issues, article sections, author names, and more.
According to WordPress developers, over 50% of sites today utilize custom taxonomies. They have become a must-have tool!
Once you have these new taxonomies, custom fields take them to the next level by storing additional structured data. You can build up rich profiles for your taxonomy terms this way.
Here are some examples of useful custom fields you can add:
- Author taxonomy: Bio, headshot, birth date, education, awards
- Product taxonomy: Photos, dimensions, materials, care instructions
- Location taxonomy: Address, phone number, hours of operation
With custom taxonomies and fields combined, you unlock nearly unlimited possibilities for organizing, displaying, and querying your site content!
Let‘s look at how to add custom fields step-by-step.
Step 1 – Install Advanced Custom Fields (ACF)
To add custom fields in WordPress, you need a plugin. There are several options out there, but experts overwhelmingly recommend Advanced Custom Fields.
ACF has been around for over a decade and is used on over 300,000 WordPress sites. It‘s 100% free on WordPress.org (the paid version adds more features).
Once installed, ACF adds a "Custom Fields" menu to your admin. This is where you‘ll create your field groups and fields.
To install ACF:
- In your WordPress dashboard, go to Plugins > Add New
- Search for "Advanced Custom Fields"
- Install and activate the plugin
That‘s it! Now ACF is ready to use.
Step 2 – Add Your First Field Group
In ACF, fields must belong to a field group. This allows you to organize multiple related fields together.
For example, you may have a field group called "Author Details" with fields for bio, headshot, birth date, etc.
To add your first field group:
- Go to Custom Fields > Add New
- Give your field group a name like "Author Details"
- Leave the location as "ACF" for now
- Click "Publish" to save your field group
Now you have a container to hold your fields!
Step 3 – Add Your Custom Fields
Within your field group, it‘s time to define the actual fields. Here‘s how:
- Click "Add Field"
- Give your field a name like "Author Bio"
- Select the field type (text, image, date, etc)
- Set any additional field options like required, default value, etc
- Click "Publish" to save your changes
Repeat to add more fields to this group, like "Profile Picture", "Birth Date", "Education", etc.
The field types and options allow you to capture all kinds of data – text, images, file uploads, numbers, choices, and richer field types like repeaters and flexible content.
Step 4 – Set Field Group Location
By default, your field group won‘t show up anywhere yet. You need to set rules for where it should appear.
Scroll down to the "Location" settings at the bottom of the field group edit screen.
For a taxonomy, you want to select these rules:
- Select "Taxonomy"
- Set "is equal to"
- Choose the taxonomy these fields should show on
Now your fields will appear when editing or adding terms in that custom taxonomy!
You can add multiple location rules to apply fields to multiple taxonomies. Super flexible!
Step 5 – Populate Your Field Data
Your fields are ready to use, but they don‘t contain any data yet. You‘ll need to populate them for each of your taxonomy terms.
When editing or adding terms, you‘ll now see the custom fields:
Go through and add data for all the different terms. Don‘t forget to save/publish them!
This might take some time, but now you‘ll have detailed profiles for all your taxonomy terms.
Step 6 – Displaying Fields on the Front-end
The fields save perfectly in the backend, but they won‘t show on the front-end by default. You need to edit your theme templates to display them.
Here is a simple example to show a field in a taxonomy archive:
// Get the term object
$term = get_queried_object();
// Get the field value
$bio = get_field(‘author_bio‘, $term);
// Output the field
echo $bio;
Using get_queried_object
, we can grab the taxonomy term. Then get_field()
retrieves the value of our custom field. Just print it out!
You can also load the values into variables and use them throughout your templates – loop, single term pages, etc.
With a few lines of code, you unlock the power of your custom fields on the front-end. Display them, use them in conditionals and loops, and more.
Key Takeaways and Next Steps
Let‘s recap what we covered:
- Custom taxonomies help you organize and group content beyond posts
- Custom fields allow you to store detailed meta data with those taxonomies
- The ACF plugin provides an easy interface for adding fields
- With custom taxonomies and fields combined, the possibilities are endless!
Next I recommend exploring additional field types like repeaters and flexible content for complex data. Also look into using ACF‘s global fields that aren‘t tied to a post or term.
Thanks for reading – I hope this guide provided lots of value for using custom fields and taxonomies on your site! Let me know if you have any other questions.