Support » Themes and Templates » Increasing excerpt length

Increasing excerpt length

  • mattstat


    I wanted to increase the excerpt length and I ran up against the WordPress wall.

    In order to do it, edit the functions.php and find all the places where “55” is and set it to the new max length (I picked 100) and then add:

    add_filter(‘excerpt_length’, ‘my_excerpt_length’);
    function my_excerpt_length($length) {
    return 100; // Or whatever you want the length to be.

    Which I found from this page;

    Better would be to create a variable, say, $max_excerpt_length and insert that into the relevant places in functions.php.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Doodlebee


    You mean use something like this in your *theme* functions.php 9ratehr than edit core code), right?

    function fix_the_excerpt($text) {
      return str_replace('[...]', '...', $text);
    add_filter('the_excerpt', 'fix_the_excerpt');
    function my_excerpt_length($length) {
      return 20; // Or whatever you want the length to be.
    add_filter('excerpt_length', 'my_excerpt_length');

    Alternatively, you could use this plugin.

    buddha trance


    @doodlebee – Thank you for your great solution! I don’t like editing core files either (better to have a smooth upgrade without having to remember stuff months later) and the theme functions.php code is perfect. 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Increasing excerpt length’ is closed to new replies.