srikat

Untitled

Oct 3rd, 2016
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. //* Limit Product Title to n Characters
  2. function shorten_woo_product_title( $title, $id ) {
  3. if ( is_shop() || is_product_tag() || is_product_category() ) {
  4. if ( strlen( $title ) >= 32) { // if the product title is longer than n characters
  5. return substr( $title, 0, 32 ) . '...'; // Shorten it to be char limit and add ellipsis at the end
  6. } else {
  7. return $title; // return the normal product title
  8. }
  9. }
  10. }
  11. add_filter( 'the_title', 'shorten_woo_product_title', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment