badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

Reply To: Services Widget on Home Page – Change length of quoted text

#13312
David
Member

Ok – I took a stab at this myself. Here is what I did if anyone else wants to do this…

first I made a function.php file in my child theme and added the following function

function get_excerpt(){
$excerpt = get_the_content();
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, 140);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
$excerpt = $excerpt = '<p>'.$excerpt.'... </p>';
return $excerpt;
}

On 6th line you can change the 140 to however many characters you like.

Then on line 338 of inc/widgets/interface_widgets.php I changed the code to
<?php get_excerpt(); ?>

I tried making a copy of the file with the changes in my child theme but it won’t override the parent theme – therefore this change will be lost upon updating. Anyone got any thoughts on how to accomplish this without losing the changes on the next update?