My blog is photo-oriented and the theme has a special excerpt function that, for better or for worse, I'd like to keep using. Anyway, it displays the excerpt and then the "More", but it just completely cuts of the excerpt, which I think looks a bit odd, especially mid sentence.

Not really sure what kind of change has to be made here, and would if go into the custom excerpt function itself, or as a separate function called by the excerpt function?

  • Without seeing the "special excerpt function" I don't see how this can be answered.
    – s_ha_dum
    Jul 3, 2013 at 16:08
  • Agree with @s_ha_dum. However, one would think you could determine if your excerpt string is longer than the full string, and if so, append some characters to indicate there is more information. strlen() - php.net/manual/en/function.strlen.php
    – GhostToast
    Jul 3, 2013 at 16:26

2 Answers 2


I have a custom except function I use all the time, it will cut off in the middle of a sentence, but it works great. Just drop this baby into your functions.php and then <?php the_excerpt_truncate(100); ?> just change the 100 to your desired character limit.


function the_excerpt_truncate($charlength) {
    $excerpt = get_the_excerpt();

    if ( mb_strlen( $excerpt ) > $charlength ) {
        $subex = mb_substr( $excerpt, 0, $charlength - 5 );
        $exwords = explode( ' ', $subex );
        $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
        if ( $excut < 0 ) {
            echo mb_substr( $subex, 0, $excut );
        } else {
            echo $subex;
        echo '...';
    } else {
        echo $excerpt;
  • Thanks for this. It works! just a small problem though -- I want the character length to be about 700, but when I do this it doesn't change from when I have it at 450 characters (which works) Jul 4, 2013 at 10:21

You can specify the length of the excerpt with this function (hopefully your custom function is using this to trim the length)

function custom_excerpt_length( $length ) {
    return 99999; //or something bigger
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

There's more information on excerpt customizing here: http://codex.wordpress.org/Function_Reference/the_excerpt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.