Ultimate guide to coding WordPress custom taxonomies for custom post types using ACF without plugins

The Smart Developer’s Guide to WordPress Custom Fields with ACF

Introduction – Why Custom Fields Are the Foundation of Quality Content

You’ve already built a Custom Post Type (CPT) such as “Reviews” and given it structure with a Custom Taxonomy like “Genre.”
Now it’s time to add rich data that turns a plain post into structured, professional content.

If you rely only on the default WordPress editor, you lose consistency.
How can you ensure every reviewer adds a star rating, a summary, and a product link?
You can’t — unless you use Custom Fields.

The Solution: Custom Fields via ACF

Custom Fields let you define dedicated input boxes for specific data points.
We’ll use the Advanced Custom Fields (ACF) plugin for the admin UI, then write clean PHP in your theme to display the data exactly how you want.

Prerequisites

  • A “Review” CPT (slug: review) already set up.
  • A custom template file: single-review.php.
  • The free Advanced Custom Fields plugin installed.

Phase 1: Creating the Fields (Using the ACF UI)

Step 1: Create a New Field Group

Go to ACF → Field Groups → Add New.
Name the group “Review Details.”

Step 2: Add Your Custom Fields

Field LabelField TypeSettingsPurpose
Star RatingNumberMin 1 – Max 5Consistent numeric rating input
Review SummaryText AreaRows = 5Dedicated space for a brief summary

Step 3: Assign the Field Group to Your CPT

Under Location Rules, set:

Show this field group if Post Type is equal to Review

Then click Publish.
Now, when editing a Review, you’ll see a Review Details box with your fields.

Phase 2: Displaying the Fields (With PHP Code)

Your structured data is stored but invisible until you render it in your template.
Open your single-review.php and, inside the loop, add the following:

<?php
the_title('<h1 class="review-title">', '</h1>');
the_content();

// --- START CUSTOM FIELD CODE ---
$star_rating = get_field('star_rating');
$review_summary = get_field('review_summary');

if( $star_rating || $review_summary ): ?>
    <aside class="review-details-box">
        <?php if( $star_rating ): ?>
            <p class="rating">
                <strong>Review Score:</strong>
                <?php echo esc_html( $star_rating ); ?>
                <span class="max-score">/ 5 Stars</span>
            </p>
        <?php endif; ?>

        <?php if( $review_summary ): ?>
            <div class="summary">
                <h3>The Verdict</h3>
                <?php the_field('review_summary'); ?>
            </div>
        <?php endif; ?>
    </aside>
<?php endif; ?>
// --- END CUSTOM FIELD CODE ---
?>

Why Use get_field() vs the_field()?

  • get_field() → Retrieves a value (great for logic, validation, or escaping).
  • the_field() → Prints the value directly (quick display).

Here, we sanitize the number field using esc_html() but print the summary directly since it’s trusted input.
This distinction is what makes ACF flexible and safe.

Design Synergy 💡 (By Zara)

Structured numeric data unlocks dynamic design.
A Star Rating field can drive CSS or JavaScript animations — filling star icons or animating progress bars in real time.
Clean, typed data = modern, interactive UI.

Conclusion + Next Steps

You’ve now completed the developer’s trilogy:

  1. Custom Post Type – Defines your content.
  2. Custom Taxonomy – Organizes it.
  3. Custom Fields – Enriches it with structured data.

You now have a lightweight, professional system with no unnecessary plugins and maximum control.

➡️ Next Guide: Mastering WP_Query – Pull Custom Content Anywhere on Your WordPress Site

Leave a Comment

Your email address will not be published. Required fields are marked *