Support » Plugin: WooCommerce » echo $product_cat not working

  • $terms = get_the_terms($post->ID, ‘product_cat’);
    foreach ($terms as $term) {
    $product_slug = $term->slug;
    $product_slug = $term2->slug;
    break;
    };

Viewing 2 replies - 1 through 2 (of 2 total)
  • The variable $term2 does not exist.

    The break; will prematurely end the loop.

    There is no echo.

    $terms = get_the_terms($post->ID, ‘product_cat’);
    foreach ($terms as $term) {
      echo $term->slug;
    }
    
    Thread Starter jonasrafael

    (@jonasrafael)

    thanks dude!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘echo $product_cat not working’ is closed to new replies.