Home › Forums › General Issues › Howto Inject Category Slug into get_field › Reply To: Howto Inject Category Slug into get_field
Yes, so $categories[0]->slug should now hold the correct value that you were looking for. You should be able to loop through this array and do what you were looking to do, something like
$categories = get_the_terms($post_id, 'product_cat');
foreach ($categories as $category) {
if (get_field('eref-'.$cagegory->slug')) {
echo '<div><span>REF: '.get_field('eref-'.$category->slug).'</span></div>';
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.