Shorten titles of related products

Hello!

Is there any way to limit the length of related products titles to two lines and add an ellipsis (three dots) at the end? My titles are too long and cause a bad layout problem. When the title goes over three lines, the next row of related products is shifted to the right due to lack of space:



Comments

  • Hello,

    Unfortunately, there is no setting to limit the text length and add three dots at the end.

    However, if you sent a link to your website I will check what I can suggest to you.


    Best regards

  • edited November 2022

    The site is not published (under construction), but I can give you access if you wish.

    I tried several codes to put in the php file I found on the web, but they work only for the titles on pages which is what I don't want to change.

    I found a css code that reduced the titles to one line (instead of two), but messed up all the rest, so I deleted it.

  • Please send us WordPress dashboard access privately thru the contact form, which is on the right side at http://themeforest.net/user/muffingroup#contact and we will check what might be the reason.

    Notice!

    Please attach a link to this forum discussion.

    Sending incorrect or incomplete data will result in a longer response time.

    Therefore, please make sure that the data you are sending are complete and correct.

    Thanks

  • I have placed a custom CSS code in your theme options that change it.

    Please, check if it is what you wanted to achieve.


    Best regards

  • I changed your code to show two lines of text, now it's perfect.

    Thank you so much for your help!

  • Hi, could you share the css code, I want to do the same

  • Hi Vitaminasocial!

    Sure, here is it:

    .woocommerce-page .column_product_related .products .product .mfn-li-product-row-title .title{

    overflow: hidden;

    text-overflow: ellipsis;

      display: -webkit-box;

      -webkit-line-clamp: 2;

          line-clamp: 2; 

      -webkit-box-orient: vertical;

    }

  • Hello!

    The code works, but I still have the problem that when the title is shorter (one line only), the next row of related products is shifted. I tried to add some margin, but this didn't solve the problem. What can I do?


  • Please, add the following CSS code:

    .woocommerce ul.products.columns-5 li.product:nth-child(5n+1), 
    .woocommerce-page ul.products.columns-5 li.product:nth-child(5n+1) {
     clear: both;
    }
    

    Thanks

  • This works perfectly. Thank you so much Phil!

Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.