Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Excerpt Length on Widget WordPress

  • SOLVED

Hello, I have a widget that I am using on this temporary site: http://ssmd.vextras.com/about/ to show client testimonials; it can viewed in the top right hand corner. I can't seem to figure out how to control the widget excerpt length.

It would optimal to control it with a set number of characters and put a "Read More" link under it to jump to a certain page where the client testimonials are located.

Any help is appreciated.

Thanks!

Answers (4)

2012-07-20

Manoj Raj answers:

We can achieve this in jquery...

Create a new page "Testimonials" with all testimonials in it... I assume the page as "http://ssmd.vextras.com/testimonials/" now

Then add the following jquery to your header

jQuery(function(){
jQuery(".slides_control div").each(function(i){
len=jQuery(this).text().length;
var link = jQuery(this).attr("id");
if(len>100)
{

jQuery(this).text(jQuery(this).text().substr(0,100)+'...');
jQuery(this).append('<a href="http://ssmd.vextras.com/testimonials/#'+link+'">Read more...</a>');
}
});
});


Now the above jquery read more link will lead you to the corresponding testimonial's area...


Kyle Hungate comments:

I put this at the very end of the header.php file and it did not work with the above code. This is what it looked like (attached).