Hi
While in essence what you are asking for is reasonable, the whole point of manual excerpts is to give you complete control over the contents of the excerpt, including its length, and the ability to use HTML tags, images, etc. in manual excerpts, that are stripped out of regular excerpts. When you put a length filter on a manual excerpt you also have to strip out HTML tags including links, because you will likely split the excerpt in the middle of a tag.
It is possible to filter manual excerpts, but doing so is like paddling upstream against the current, in terms of overriding the whole reason manual excerpts were created in the first place. The simplest way to filter length on manual excerpts is write them shorter.
That said, if you really really need to filter manual excerpts you can do it. They are found in $post->post_excerpt
you can achieve what you want with this method:
‘Automatically Shorten the Manual Excerpt’, however, this approach also removes the html tags/formatting from the manual excerpt.
Thanks for the reply. I found some code that did the trick.
<?php
$len = 200; //Number of words to display in excerpt
$newExcerpt = substr($post->post_excerpt, 0, $len); //truncate excerpt according to $len
if(strlen($newExcerpt) < strlen($post->post_excerpt)) {
$newExcerpt = $newExcerpt."[...]";
}
echo "<p>".$newExcerpt."</p>"; //finally display excerpt
?>
What can I do to add
<?php the_excerpt(); ?>
to the code so if there isn’t a manual excerpt it will display the auto excerpt?
example:
<?php
if( $post->post_excerpt ) : //checks for manual excerpt
$len = 200; //Number of words to display in excerpt
$newExcerpt = substr($post->post_excerpt, 0, $len); //truncate excerpt according to $len
if(strlen($newExcerpt) < strlen($post->post_excerpt)) {
$newExcerpt = $newExcerpt."[...]";
}
echo "<p>".$newExcerpt."</p>"; //finally display excerpt
else :
the_excerpt();
endif;
?>