Home Forums Themes Support Claue Show Category

Topic Resolution: Resolved
Viewing 2 reply threads
  • Author
    Posts
    • #23418

      Hi,
      I would like to show categories below/above the title of the products in Shop Page and in single Product Page, but I can’t find this function anywhere.
      How could I add/show it?

      Thanks

    • #23461

      Hi,

      Please add below code to claue-child > functions.php

      add_action( 'woocommerce_shop_loop_item_title', 'VS_woo_loop_product_title', 25 );
       
      function VS_woo_loop_product_title() {
          $terms = get_the_terms( $post->ID, 'product_cat' );
          if ( $terms && ! is_wp_error( $terms ) ) :
          // only displayed if the product has at least one category
              $cat_links = array();
          foreach ( $terms as $term ) {
              $cat_links[] = '<a href="'.esc_url( home_url() ).'/product-category/'.$term->slug.'">'.$term->name.'</a>';
          }
          $on_cat = join( ", ", $cat_links );
          ?>
          <div class="categories-link db"><?php echo $on_cat; ?></div>
      <?php endif;
      }
      
      add_action( 'woocommerce_single_product_summary', 'product_category_name', 3 );
       
      function product_category_name() {
          $terms = get_the_terms( $post->ID, 'product_cat' );
          if ( $terms && ! is_wp_error( $terms ) ) :
          // only displayed if the product has at least one category
              $cat_links = array();
          foreach ( $terms as $term ) {
              $cat_links[] = '<a href="'.esc_url( home_url() ).'/product-category/'.$term->slug.'">'.$term->name.'</a>';
          }
          $on_cat = join( ", ", $cat_links );
          ?>
          <div class="categories-link db w__100 mb__5"><?php echo $on_cat; ?></div>
      <?php endif;
      }

      and add below code to Claue > Theme Option > General Layout > Custom CSS

      .jas-wc-single .entry-summary > .categories-link,
      .product-quickview .entry-summary > .categories-link {
          margin-bottom: 0px;
      }

      Best regards

      Harry
      Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio

    • #23516

      Awesome. Thank you

Viewing 2 reply threads

You must be logged in to reply to this topic.