logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$5
Excerpt Length on Widget

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!

This question has been answered.

attachment image View Attachment

Kyle Hungate | 07/20/12 at 10:48am Edit


(4) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    07/20/12
    10:51am
    Michael Caputo says:

    What widget plugin are you using?

    • 07/20/12 10:53am

      Kyle Hungate says:

      It is a widget that was included with the Wootheme (Whitelight) called "Feedback".

    • 07/20/12 10:55am

      Michael Caputo says:

      I don't see a way to do it without editing the widget code.

    • 07/20/12 10:56am

      Michael Caputo says:

      You could do it with a bit of javascript...

    • 07/20/12 11:11am

      Michael Caputo says:

      Try this JS (untested)


      <script type="text/javascript">
      var code_2_sample_full_desc = $("blockqote.feedback-text").text()
      var code_2_sample_short_desc = $("blockqote.feedback-text").text() // get the text within the div
      .trim() // remove leading and trailing spaces
      .substring(0, 100) // get first 600 characters
      .split(" ") // separate characters into an array of words
      .slice(0, -1) // remove the last full or partial word
      .join(" ") + "..."; // combine into a single string and append "..."
      $('blockqote.feedback-text').html(code_2_sample_short_desc + '<br><a href="#" onClick="show_all()">(show all)</a>')
      function show_all () {
      $('blockqote.feedback-text').html(code_2_sample_full_desc + '<br><a href="#" onClick="show_less()">(show less)</a>')
      _gaq.push(['_trackEvent', 'toggle', 'click', 'show code_2_sample'])
      }
      function show_less () {
      $('blockqote.feedback-text').html(code_2_sample_short_desc + '<br><a href="#" onClick="show_all()">(show all)</a>')
      _gaq.push(['_trackEvent', 'toggle', 'click', 'hide code_2_sample'])
      }
      </script>

  • avatar
    Last edited:
    07/20/12
    10:54am
    Arnav Joy says:

    for the widget "widget_woo_feedback" you have to edit it on the file if it there is no option for it in the admin panel to set the no. of characters.

    • 07/20/12 10:55am

      Kyle Hungate says:

      Correct - there is no option to modify in the admin panel

    • 07/20/12 10:56am

      Arnav Joy says:

      then you have to work on the widget..

  • avatar
    Last edited:
    07/20/12
    11:28am
    Manoj Raj says:

    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...

    • 07/22/12 9:00pm

      Kyle Hungate says:

      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).

      Attached Image

    • 07/22/12 9:27pm

      Manoj Raj says:

      you need to enclose the tag inside the <script> tag... Have you done that?


      <script type="text/javascript">
      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>');

      }

      });

      });
      </script>

  • avatar
    Last edited:
    07/22/12
    5:51am

    This answer was downvoted by the top experts.

This question has expired.



Gabriel Reguly, Kyle Hungate voted on this question.



Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.