You could add this to your functions file of your child theme.
function description_in_shop_loop_item() {
global $product;
$limit = 35; //number of characters
$description = $product->get_description();
if (strlen($description) > $limit) {
$excerpt = substr($description, 0, $limit) . '...';
} else {
$excerpt = $description;
}
echo '<p class="description">'.$excerpt.'</p>';
}
Stef thanks where would I add it in the child theme? in the functions.php of the child theme?
Take a screenshot of your functions file use something like imgur or snag.gy to post to
You want to add it right after the
<?php
Or at the very bottom. It depends. Some themes have nothing in their functions folders nowadays.
-
This reply was modified 6 years, 10 months ago by
Stef.
Here it is I added it at the bottom but it did nothing
View post on imgur.com
Looks good. Although I never advise editing in the Theme Editor. Always try and use SFTP/FTP when you can.
oh ok new to all this… so it is in place but the text is not being shortened/truncated on the home page
View post on imgur.com
You have to clear your cache every time you add code or do file edits.
Open in a private browser if you don’t know how to clear cache
I did clear cache and tested in firefox and chrome plus incognito window still shows full text
You sure you added it to the Storefront theme and not the TwentyNineteen theme? All the more reason to learn SFTP/FTP.
Look at the Drop Down when in Theme Editor to the right. Make sure Storefront Child is selected. Make sure you also have the latest Storefront installed.
Powerpack maybe blocking it but I doubt it. Tested on mine and it works.
yes if you look at the first picture I sent it also confirms the child theme is active and I just viewed the ftp file and it is correct
How are you achieving the short description on that page? Shortcode?
no it is feed in from woocommece storefront automatically it is an option to select
The only thing I think it could be is you copied it and your computer changed the quotes. Meaning it reformatted the ‘ character
I have it working on my demo site using all: recent, best selling, featured, etc.
-
This reply was modified 6 years, 10 months ago by
Stef.
Also, if you used a snippet to add the short description to these you’ll need to remove it because by default this is not part of the theme. My code takes care of both.
ok ill go to the file direct and type your text into it and ftp it. the test comes from the short description page for the product direct.
thank you