Woocmmerce Title Shortener

PHOTO EMBED

Mon Sep 06 2021 04:08:58 GMT+0000 (Coordinated Universal Time)

Saved by @shadowtek

add_filter( 'the_title', 'shorten_woo_product_title', 10, 2 );
function shorten_woo_product_title( $title, $id ) {
    if ( ! is_singular( array( 'product' ) ) && get_post_type( $id ) === 'product' && strlen( $title ) > 30 ) {
        return substr( $title, 0, 25) . '…'; // change last number to the number of characters you want
    } else {
        return $title;
    }
}
content_copyCOPY