WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How To change Excerpt Length Depending on the page

[Resolved] How To change Excerpt Length Depending on the page

  • I have some code displaying excerpts in the side bar – I want the snippet of the post to be a different length to that displayed when you go to the events category page.

    I have this so far in my functions.php file but it doesn’t work.

    function custom_excerpt_length($length) {
        if (is_page('Events')) {  //For the events page
            return 65;
        } else {
            return 40; //for all others pages
        }
    }
    add_filter('excerpt_length', 'custom_excerpt_length');

    “Allowed markup: a blockquote code em strong ul ol li.
    Put code in between backticks.”

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] How To change Excerpt Length Depending on the page’ is closed to new replies.
Skip to toolbar