Text-overflow: Error!

Hi, I want to test below code and I want to shorten product title in my shop page and categories but I can not test the codes text-overfollow error ! What is problem ? I want to do in xxxxxxxx… For example after 10 characherter it will be …

My Error !

website to check
www.fabrika-satis.com

The codes

.woocommerce ul.products li.product h3 {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

Thank you so much!
Have a nice day!

I do not help anymore because ı solved different with very nice code… ıf you need I can share.

Have a nice day !

Hi,

Great! I’m glad it’s resolved! If you want you can share the code with what you have fixed the issue.

Best Regards,
Csaba

Hi @Csaba ,

I am sharing the codes . And you can see action in below link images.

I only change orginal numbers from 10 to 30 …
Because best number in theshop theme 30 character…

add_filter(‘the_title’, ‘modify_title’, 30);
function modify_title( $title ) {
if ( is_woocommerce() || is_product_category() ) {
if ( strlen( $title ) > 30 ) {
$title = substr($title, 0, 30).’…’;
}
}
return $title;
}

Not: The codes works in function.php
Thank you so much!
Have a nice day !

And I find different code. And I suggest this codes. Becuase this only shorten list pages not product page…

/* title shorten2 */
function short_woocommerce_product_titles_chars( $title, $id ) {
if ( ( is_shop() || is_product_tag() || is_product_category() ) && get_post_type( $id ) === ‘product’ ) {
if ( strlen( $title ) >= 30) { // Kicks in if the product title is longer than 60 characters
return substr( $title, 0, 30 ) . ‘…’; // Shortens it to 10 characters and adds ellipsis at the end
} else {
return $title; // If the title isn’t longer than 60 characters, it will be returned in its full length without the ellipsis
}
} else {
return $title;
}
}
add_filter( ‘the_title’, ‘short_woocommerce_product_titles_chars’, 10, 2 );

Hi,

Thank you for sharing the codes. If you need help with anything else, please open a new topic.

Have a nice day!

Best Regards,
Csaba