Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards!

how to add a custom text to product title?

Theme and Plugin Support

Tagged: 

Resolved
Viewing 2 reply threads
  • Author
    Posts
    • #141091
      Tim Kerremans
      Participant

      I am trying to add product category to the product title using this code on functions.php on child theme but its not working the way i want, please check the attached image:
      remove_action( ‘woocommerce_single_product_summary’,’woocommerce_template_single_title’, 5 );
      add_action( ‘woocommerce_single_product_summary’, ‘custom_product_category_title’, 6 );
      function custom_product_category_title(){
      global $post;
      $terms = get_the_terms( $post->ID, ‘product_cat’ );
      $title = ”;
      foreach ($terms as $term) {
      $title = $term->name .’ ‘;
      }
      echo “<h1 class=’product_title entry-title’>”.$title.”</h1>”;
      }

      any advice would be great!

    • #141119

      Hi,
      You have to override plugins/woocommerce/templates/single-product/title.php by copying it to yourtheme/woocommerce/single-product/title.php
      add add your code.

      Regards,

    • #144887

      Hi @tim-kerremans, we haven’t heard back from you for a while.
      So we presume this issue has been fixed. We are closing this for now.

Viewing 2 reply threads

The topic ‘how to add a custom text to product title?’ is closed to new replies.