In WordPress is it possible to change the excerpt length depending on how long the title is?
I simply call the title like so:
<?php the_title(); ?>
And the excerpt:
<?php html5wp_excerpt('html5wp_index'); // in my functions.php I set the length ?>
functions.php
function html5wp_index($length);
{
return 25;
}
So if the title was 15 characters then the excerpt would only be 10 for example?
This should do the trick for you. Just place it in your functions.php file. Currently it would affect all posts or pages where
the_excerpt();
is being used, but you could wrap it in a conditional to isolate it. Just read the comments in the code for some further explanation of what’s happening.Just change the numbers to set it to your specification.