Support » Plugin: WooCommerce » shorten product title in shope page and categories with ………

  • Hi

    I want to shorten product title in shop page and categories. For example it will be after 10 characters ……….

    Example: Asdfghasdq……

    Thank you so much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I find the codes. You can change 30 number !

    function short_woocommerce_product_titles_chars( $title, $id ) {
    if ( ( is_shop() || is_product_tag() || is_product_category() ) && get_post_type( $id ) === ‘product’ ) {
    if ( strlen( $title ) >= 30) { // Kicks in if the product title is longer than 60 characters
    return substr( $title, 0, 30 ) . ‘…’; // Shortens it to 10 characters and adds ellipsis at the end
    } else {
    return $title; // If the title isn’t longer than 60 characters, it will be returned in its full length without the ellipsis
    }
    } else {
    return $title;
    }
    }
    add_filter( ‘the_title’, ‘short_woocommerce_product_titles_chars’, 10, 2 );

      // shorten product title
      // code goes in functions.php for your child theme
      add_filter('the_title', 'modify_title', 10);
      function modify_title( $title ) {
        if ( is_woocommerce() || is_product_category() ) {
          if ( strlen( $title ) > 10 ) {       
            $title = substr($title, 0, 10).'...';
          }
        }
        return $title;
      }
    
    • This reply was modified 2 years, 11 months ago by  lorro.

    Good job @lorro. Good works perfectly !

    You are very helpful person. Really I want to be friends everytime. not important websites.

    Thank you so much! I dont forget anytime like you helpful person !

    Have a great day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘shorten product title in shope page and categories with ………’ is closed to new replies.