RJ Ramirez
RJ Ramirez

Reputation: 269

How to retrieve WooCommerce Attribute as Taxonomy Term selected

I have this ACF field:

Field Name: brand
Field Type: Taxonomy
Taxonomy: pa_brand

enter image description here

WooCommerce Product Attribute:

Name: brand
slug: brand
term id: 51
value: ASUS

enter image description here

I’m trying these codes but it doesn’t work:

<?php the_field(‘brand’, $term); ?>

<?php the_field(‘brand’, ‘product_51’); ?>

Or how will I know the category to use if I’m wrong.

Upvotes: 0

Views: 499

Answers (1)

baiju jha
baiju jha

Reputation: 473

pass a object to the the_field() method see below code

  $obj = get_queried_object();

  the_field(‘brand’, $obj); 

Upvotes: 1

Related Questions