How to Display WooCommerce Product Attributes & ACF Fields with Loops and Logic

Hello L&L Community,

I’m working on a WooCommerce single product page and I’m trying to dynamically display both WooCommerce product attributes (taxonomies) and some custom fields (ACF fields) using Loops and Logic. I’ve been following the documentation, but I’m running into an issue where the data isn’t being pulled correctly.

What I’m Trying to Achieve:

  • Display WooCommerce product attributes like Vehicle Type, Body Style, Fuel Type, and Warranty (these are custom attributes stored as taxonomies like pa_vehicle_type, pa_fuel_type, etc.).
  • Display ACF fields like Model Name, Top Speed (km/h and mph), and others.
  • Display the brand (stored in a custom taxonomy “brand-product”).

Here’s a screenshot showing the static content that I’m trying to replace with dynamic fields from Loops and Logic:

And here’s the URL of the specific product page I’m working on:

https://totalpowersports.dev/inventory/atvs/kids-atvs/kids-gas-atvs/gio-blazer-125hs-hunter-kids-utility-atv/

The Code I’m Using:

The Issue:

  • None of the fields or attributes are displaying on the product page.
  • I’ve used post=“current” in the loop to target the current product, but it doesn’t seem to work.
  • I’m unsure if I’m calling the WooCommerce attributes (like pa_vehicle_type, pa_fuel_type) or custom taxonomies (like brand-product) correctly in Loops and Logic.

What I Need Help With:

  • How do I properly query and display WooCommerce product attributes (which are taxonomies like pa_vehicle_type) using Loops and Logic?
  • Is there a better way to ensure the loop is targeting the current product on a WooCommerce single product page?
  • How do I correctly display custom taxonomies like brand-product within the loop?

Any assistance or insights would be greatly appreciated.

Thanks in advance,

Matt

Hi @mattsfraser, maybe you can try this code to output the taxonomies for product attributes. You can use id=“current” in the query to get the info of the current product

<Loop post_type="product" id="current">
  <ul class="product-details">
    <Taxonomy pa_vehicle_type>
      <li><strong>Vehicle Type:</strong> <Term title /></li>
    </Taxonomy>
  </ul>
</Loop>

<Note>Method 2</Note>
<Loop post_type="product" id="current">
  <ul class="product-details">
    <If loop taxonomy=pa_vehicle_type post="current">
      <Loop taxonomy=pa_vehicle_type post="current">
        <li><strong>Vehicle Type:</strong> <Field title /></li>
      </Loop>
    </If>
  </ul>
</Loop>