WordPress.org

Support

Support » Plugins and Hacks » List category posts » [Plugin: List category posts] Suggestion: Improving string cut when building excerpts

[Plugin: List category posts] Suggestion: Improving string cut when building excerpts

  • Andrey Kiselev

    @andrey-kiselev

    Hello, Fernando!
    Thanks for the grat plugin!
    Just one suggestion to improve it a little bit. When you build excerps you cut strings exactly at 252-nd char. This results in showing “black-diamond-question-mark” sometimes when cutting cyrillic strings. In order to work this out, you can cut string at a nearest space.

    So, this is your original string (CatList.php):

    $lcp_excerpt = substr($lcp_excerpt, 0, 252) . '...';

    And my suggestion is to replace it with this one:

    $lcp_excerpt = substr( $lcp_excerpt, 0, strrpos( substr( $lcp_excerpt, 0, 252 ), ' ' ) ) . '...';

    So, it just cuts excerpt at the nearest space before 252nd char.

    Cheers,
    Andrey

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: List category posts] Suggestion: Improving string cut when building excerpts’ is closed to new replies.
Skip to toolbar