• Resolved dpope0824

    (@dpope0824)


    Is there any way to limit the excerpt length by words instead of characters so we don’t have words that get cut off?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author RadiusTheme

    (@techlabpro1)

    Hello,
    I will try to add this feature in next version.

    Thanks

    Thread Starter dpope0824

    (@dpope0824)

    Thanks a lot, think that may be something more people than me could use.

    Great idea. Would appreciate this very much.

    Hello and shortly direct to the problem with my own solution to shorten your string and ending after the next possible word. You have to choice your layout template, which you are use and have configurated. I use the “Layout 1” so I look in the “layout1.php” at “lib”->”views”->”layouts” at line 46.

    Note: your Post Grid layout setting (excerpt limit) is minimum as like as our following limit number or better leave it blank. Have fun, David Harex ??

    
    if(in_array('excerpt', $items)){
    //old original
    //$html .= "<div class='post-content'>{$excerpt}</div>";
    				
    /*limit the string, choice a bigger number as in your excerpt number at the preferences!*/
    $limit=200; 
    				
    //PHP wordwrap shorten strings without to cut in two
    $text = wordwrap($excerpt, $limit, "\0"); 
    //every 200 letters we put an ASCII Code No. 0 in it. This is a realy seldom used sign and here helpfully.
    				
    /*
    divide th string. The (.*?) means all signs before the first ASCII sign and the (.*) stands for all after. The \0 repeats often but we tell them with a "?" in de ending first part, that here is the end of our shortend string. The other part is uninterested for us. And now we have our limited string.
    */
    				
    $newshortstring= preg_replace('/^(.*?)\0(.*)$/is', '$1', $text);
    $html .= "<div class='post-content'>$newshortstring...</div>";
    				
    }
    
    /*END :-D */
    • This reply was modified 7 years, 9 months ago by davidharex.
    • This reply was modified 7 years, 9 months ago by davidharex.
    Plugin Author RadiusTheme

    (@techlabpro1)

    Hi David,

    Thanks for your solution. I will add this in next versions.

    Regards,
    Mamun

    Oh Thank You very much. I use your post grid and makes me happy – great work! I use WordPress since several months and are the fastest way for me. Is there a solution for the problem with double same title in the excerpt? Normally a post use a page title and a html heading tag like <h1>. Now the post grid shows optically great grids but thera are double titles at the beginning of them. kind regards.

    Plugin Author RadiusTheme

    (@techlabpro1)

    I am not clear about double title. Please send me screenshot.

    Thanks

    Here my Preview (in german) where you can see the post_grid and the contentsite of them. The Title is double listed “Grundf?higkeitsversicherung” for example.

    The Post Grid: https://v2.die-finanzkanzlei.info/wp-content/uploads/2017/02/doubleTitle_post_grid.jpg

    The content: https://v2.die-finanzkanzlei.info/wp-content/uploads/2017/02/doubleTitle_content.jpg

    • This reply was modified 7 years, 9 months ago by davidharex.
    Plugin Author RadiusTheme

    (@techlabpro1)

    Hi,
    Can you please is any Excerpt plugin installed?

    No one face this or check your custom code see my demo no duplicate title https://demo.radiustheme.com/wordpress/plugins/the-post-grid/layout-1/

    Thanks

    Indeed – you have right. I use pages and there is in my standard installlation no options for an individal excerpt. Now I have installed “excerpts for Pages” and put some text in there and it works finde. Perfect and thank you very much for your advice! And by the way: I dont need my modification because the extra excerpts limits my text output automatically. Sometimes you did not seen all other solutions s when you stand in front of one ??

    • This reply was modified 7 years, 9 months ago by davidharex.
    Plugin Author RadiusTheme

    (@techlabpro1)

    ok Nice

    So all is ok now.

    Thanks

    Plugin Author RadiusTheme

    (@techlabpro1)

    Hello,
    I added this feature in Version 1.6.

    Thanks

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Excerpt length Words’ is closed to new replies.