Shop Page - Display Product's Categories within Description

I've been searching the forum widely but unfortunately due to the keywords involved I'm getting multiple different discussions. So to be specific I'm not talking about simply displaying "Categories" on a page but instead to show each products individual categories in which they were assigned to on the shop page. I'm looking to accomplish this https://www.teacherspayteachers.com/Browse/Grade-Level/Pre-K in which each product's categories are below the product's description.

I welcome any and all suggestions!

Comments

  • Also if you have any suggestion as to why the following codes within the function.php, theme-functions.php and in /theme-woocommerce.php doesn't show even though in other themes it does?

    function woo_show_excerpt_shop_page() {
        global $product,$post;

        echo $product->post->post_excerpt;
       
        $subject_categ = $product->get_categories();
        echo '<div>Subjects:'.$subject_categ.'</div>';       
      
        $brands_id = get_term_by('slug', 'subjects', 'product_cat');

        $terms = get_the_terms($post->ID, 'product_cat');
        foreach ($terms as $term) {
         if($term->parent === $brands_id->term_id) {
            echo '<div>Subjects2:'.$term->name.'</div>';
            break;
        }
    }

    }
  • Hello,
    the sollution is very simple but very complicated due to Wocommerce options...
    You have to edit the shop page in the Wordpress customizer and set this option there.
    thanks
Sign In or Register to comment.