Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //* Limit Product Title to n Characters
- function shorten_woo_product_title( $title, $id ) {
- if ( is_shop() || is_product_tag() || is_product_category() ) {
- if ( strlen( $title ) >= 32) { // if the product title is longer than n characters
- return substr( $title, 0, 32 ) . '...'; // Shorten it to be char limit and add ellipsis at the end
- } else {
- return $title; // return the normal product title
- }
- }
- }
- add_filter( 'the_title', 'shorten_woo_product_title', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment