limit experpt length

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)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.