Hello, I need to shorten the names of products only in the archives, I achieved this with the help of a code, this code shortens the name in a quick preview. How to avoid this?
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’ ) {
return mb_strimwidth( $title, 0, 30); // change last number to the number of words you want
} else {
return $title;
}
}