Ledger Nano X - The secure hardware wallet
SHARE
TWEET

How to limit WooCommerce product title

fahimmurshed May 18th, 2020 924 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Limit WooCommerce Title
  2. // More info on https://murshidalam.com
  3. add_filter( 'the_title', 'shorten_woo_product_title', 10, 2 );
  4. function shorten_woo_product_title( $title, $id ) {
  5.     if ( ! is_singular( array( 'product' ) ) && get_post_type( $id ) === 'product' ) {
  6.         return wp_trim_words( $title, 4, '...' ); // change last number to the number of words you want
  7.     } else {
  8.         return $title;
  9.     }
  10. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top