Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function custom_single_product_summary(){
- $maxWords = 50; // Change this to your preferences
- $description = strip_tags(get_the_content()); // Remove HTML to get the plain text
- $words = explode(' ', $description);
- $trimmedWords = array_slice($words, 0, $maxWords);
- $trimmedText = join(' ', $trimmedWords);
- if(strlen($trimmedText) < strlen($description)){
- $trimmedText .= ' — <a href="' . get_permalink() . '">Read More</a>';
- }
- echo $trimmedText;
- }
Add Comment
Please, Sign In to add comment