Forums Forums Search & Filter Pro limit experpt length

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #30191

    How can I set the limit of the excerpt ?

    Anonymous
    #30193

    I thought this might work but it doesn’t:

    <p><?php substr( the_excerpt(), 0, 125); ?><p>

    Ross Moderator
    #30212

    Please take a look at the WordPress codex entry for this function and correct usage:

    https://codex.wordpress.org/Function_Reference/the_excerpt#Control_Excerpt_Length_using_Filters

    I can already see the bit of code you want is there:

    function custom_excerpt_length( $length ) {
    return 20;
    }
    add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );

    In addition, I believe the_excerpt() echos the output immediately- so substr won’t work as its not placed inside a variable.

    Thanks

    Anonymous
    #30216

    That worked!

    Thank you! 🙂

Viewing 4 posts - 1 through 4 (of 4 total)