-
AuthorPosts
-
June 17, 2022 at 12:05 pm #1355590
Hi all,
I’m trying to get the product columns on the same level on the Woocommerce shop page. Given the different lengths in terms of product title and product short description.
The intention is that the short product description is shortened so that all columns are at the same height.
What options are there?
- This topic was modified 2 years, 6 months ago by thijmens.
June 17, 2022 at 1:51 pm #1355607Hey thijmens,
Please try the following in Quick CSS under Enfold->General Styling:
@media only screen and (min-width: 768px) { div.inner_product.av-product-class- { min-height: 780px; } }
Best regards,
RikardJune 17, 2022 at 3:16 pm #1355612Thnx, that’s what I got myself.
Is it also possible to limit the short product description?
June 19, 2022 at 12:20 am #1355728Hi,
Thank you for the link to your site, try adding this code to the end of your functions.php file in Appearance ▸ Editor:function custom_limit_words_script() { ?> <script> (function($){ $('#top.post-type-archive-product .template-shop .products.columns-3 .product .inner_product').contents().filter(function() { return this.nodeType == 3 }).each(function(){ var length=30 this.textContent = this.textContent.split(" ",length).join(" "); }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_limit_words_script');
feel free to adjust the word length to suit, currently it is 30.
Best regards,
MikeJune 20, 2022 at 8:36 pm #1355885Thank you! This is already looking better.
How do you manage to put ‘…’ after X words? Otherwise it looks crazy that the description is suddenly shortened.
June 21, 2022 at 11:54 am #1355984Hi,
Glad to hear, try this script instead:function limit_words_script() { ?> <script> (function($){ $('#top.post-type-archive-product .template-shop .products.columns-3 .product .inner_product').contents().filter(function() { return this.nodeType == 3 }).each(function(){ var length=30 this.textContent = this.textContent.split(" ",length).join(" ") + "..."; }); })(jQuery); </script> <?php } add_action('wp_footer', 'limit_words_script');
Best regards,
MikeJune 27, 2022 at 1:43 pm #1356600This will help! But the ‘…’ shows after every product-description. It should only show behind the truncated descriptions.
June 28, 2022 at 1:31 pm #1356720Hi,
Thanks for the feedback I have adjusted the script to this:function limit_words_script() { ?> <script> (function($){ $('#top.post-type-archive-product .template-shop .products.columns-3 .product .inner_product').contents().filter(function() { return this.nodeType == 3 }).each(function(){ var words=45 if (this.textContent.length > 347) { this.textContent = this.textContent.split(" ",words).join(" ") + "..."; } }); })(jQuery); </script> <?php } add_action('wp_footer', 'limit_words_script');
To understand how this works please note that since the script doesn’t know “words” and words are different lengths the script counts the spaces between the words to equal the desired “45”, the conditional property “length” counts characters, so in my test with
console.log(this.textContent.length)
for your language the average character length for 45 spaces, or words, is 347.Best regards,
MikeJune 30, 2022 at 11:07 am #1356928is there a way to see the page it belongs to?
I’m participant as you are – but sometimes we do also have good ideas ;) -
AuthorPosts
- You must be logged in to reply to this topic.