Advertisement
salmancreation

woo product title shorten

May 2nd, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. add_filter( 'the_title', 'shorten_woo_product_title', 10, 2 );
  2. function shorten_woo_product_title( $title, $id ) {
  3. if ( ! is_singular( array( 'product' ) ) && get_post_type( $id ) === 'product' ) {
  4. return wp_trim_words( $title, 4, '...' ); // change last number to the number of words you want
  5. } else {
  6. return $title;
  7. }
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement