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');
Written by Daniel Hodkinson
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#