Title: Truncating text
Last modified: June 2, 2019

---

# Truncating text

 *  [matheny00](https://wordpress.org/support/users/matheny00/)
 * (@matheny00)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/)
 * I am using woocommerce storefront with power pack and have talked to their support
   with no luck on this issue. On the home page woocommerce feeds in multiple topics
   and products and i like that what I do not like is the fact that the short description
   is so long making the page much longer than needs to be. I would like to truncate
   that text to 2 lines or so many words, letters etc…
    I have had no luck with 
   everything on line so hope someone here can help. Thank you
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ftruncating-text%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 15 replies - 1 through 15 (of 27 total)

1 [2](https://wordpress.org/support/topic/truncating-text/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/truncating-text/page/2/?output_format=md)

 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11595898)
 * 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>';
       }
       ```
   
 *  Thread Starter [matheny00](https://wordpress.org/support/users/matheny00/)
 * (@matheny00)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11595912)
 * Stef thanks where would I add it in the child theme? in the functions.php of 
   the child theme?
 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11595917)
 * 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](https://wordpress.org/support/users/serafinnyc/).
 *  Thread Starter [matheny00](https://wordpress.org/support/users/matheny00/)
 * (@matheny00)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11595937)
 * Here it is I added it at the bottom but it did nothing
 * > [View post on imgur.com](https://imgur.com/syfbLkE)
 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11595939)
 * Looks good. Although I never advise editing in the Theme Editor. Always try and
   use SFTP/FTP when you can.
 *  Thread Starter [matheny00](https://wordpress.org/support/users/matheny00/)
 * (@matheny00)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11595945)
 * 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](https://imgur.com/PsGCZAf)
 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11595958)
 * 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
 *  Thread Starter [matheny00](https://wordpress.org/support/users/matheny00/)
 * (@matheny00)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11595973)
 * I did clear cache and tested in firefox and chrome plus incognito window still
   shows full text
 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11595988)
 * 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.
 *  Thread Starter [matheny00](https://wordpress.org/support/users/matheny00/)
 * (@matheny00)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11595990)
 * 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
 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11596007)
 * How are you achieving the short description on that page? Shortcode?
 *  Thread Starter [matheny00](https://wordpress.org/support/users/matheny00/)
 * (@matheny00)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11596024)
 * no it is feed in from woocommece storefront automatically it is an option to 
   select
 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11596032)
 * 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](http://serafindesigns.com/projects/dev_one/)
   using all: recent, best selling, featured, etc.
    -  This reply was modified 6 years, 10 months ago by [Stef](https://wordpress.org/support/users/serafinnyc/).
 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11596035)
 * 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.
 *  Thread Starter [matheny00](https://wordpress.org/support/users/matheny00/)
 * (@matheny00)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/#post-11596040)
 * 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

Viewing 15 replies - 1 through 15 (of 27 total)

1 [2](https://wordpress.org/support/topic/truncating-text/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/truncating-text/page/2/?output_format=md)

The topic ‘Truncating text’ is closed to new replies.

## Tags

 * [short description](https://wordpress.org/support/topic-tag/short-description/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 27 replies
 * 2 participants
 * Last reply from: [matheny00](https://wordpress.org/support/users/matheny00/)
 * Last activity: [6 years, 10 months ago](https://wordpress.org/support/topic/truncating-text/page/2/#post-11596207)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
