WooCommerce shortens product title

Spread the love

WooCommerce shortens product title   IN Edit Themes ( functions.php  )

We use a code snippet from here to shorten long product titles. Something like this:

  1.   teach you 

 

https://wordpress.org/support/topic/shorten-related-products-titles/

 

 

or use

function short_woocommerce_product_titles_chars( $title, $id ) {
  if ( ( is_shop() || is_product_tag() || is_product_category() ) && get_post_type( $id ) === 'product' || is_page_template('taxonomy-range-archive.php') ) {
    if ( strlen( $title ) >= 30) { // Kicks in if the product title is longer than 30 characters 
      return substr( $title, 0, 30 ) . '...'; // Shortens it to 30 characters and adds ellipsis at the end
    } else {
      return $title; // If the title isn't longer than 30 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 );

 

 

  •  
  •  
  •  
  •  
  •  

发表评论

WhatsApp contack me whatsapp
shipping cart
There are no products in the cart!
Subtotal
$0.00
Total
$0.00
Continue Shopping
0