Support

Account

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>';
        }
    }