Last Updated: February 25, 2016
·
1.276K
· danhodkinson

Multiple Excerpts in Wordpress

I had been trying to figure out the best way to go about creating different excerpts for my home page, news page, archive page etc but didn't want to have to change the code from the standard <?php the_excerpt();?>

In the end I just decided to play along with the standard wordpress function but add a few if/else statements so that i could choose how long the excerpt was based on the page I was on.

function my_excerpt_length($length) {

if (is_front_page()) {
    return 12;
    }
 else {
    return 50;
    }
}
add_filter('excerpt_length', 'my_excerpt_length');