limit product titles letters on upsell and related products.

[ad_1]

i need to limit product titles letters on upsell and related products. and add … three dots to end of the title.

i use this code. it is not working

function custom_related_products_title_length( $title, $id ) {
if ( get_post_type( $id ) !== ‘product’ ) {
return $title;
} else {
return wp_trim_words( $title, 4, ‘…’ );
}
}
add_filter( ‘woocommerce_product_upsells_title’, ‘custom_related_products_title_length’, 10, 2 );

The page I need help with: [log in to see the link]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer