fbpx

how to add a custom text to product title?

Theme and Plugin Support

how to add a custom text to product title? Open

Tagged: 

Viewing 1 reply thread
  • 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!

      Attachments:
    • #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,

Viewing 1 reply thread

Please LOGIN to reply to this topic

Buy all Marketplace addons together!!

Check Slashed Price