I thought that I got this working but unfortunately it is not. I need my static home page to have an excerpt length of 50 and every other pages to have one of 20. Here is my code so far:
function custom_excerpt_length( $length ) {
if(is_front_page()) $content='excerpt';
return 50;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
I can tell it’s not working because on seamlessthemes.com the excerpt is 50, but on seamlessthemes.com/themes the excerpt is still 50. Please note this theme had a default one of 20 for some reason, so the themes page should still be 20.
Thanks in advance!
How filters work
Filters are simply a point where you can take some value, that is set (for something) in core (for e.g. the
the_excerpt()
function), in open to modifications.So…
…just says:
Excercise
Here’s an example, based on your question, that gets the variable as parameter in the function definition (the definition of the “filter callback”-function). It then modifies (in case – we use conditional tags here) it and returns it.