Help With Excerpt
-
Hello,
I’m having a problem getting excerpts to work for me. Specifically, the length and a carriage return. My understanding is the default action of Excerpt is it will pull the first 55 words – but for some reason – I’m getting the entire excerpt. Also, there’s some strange carriage return at the end of the content that isn’t in the excerpt itself. This doesn’t occur when the IF statement below uses the_content().
In short, I’m simply trying to test is the except is blank – if it is – use the content – if not – use the excerpt.
//check to see if excerpt is blank – if not use it, else use post content
if($post->post_excerpt != “”) {
$rcsample = the_excerpt();
} else {
$rcsample = get_the_content();
}
// Remove extraneous stuff from the content text
$rcstthec = strip_tags($rcsample);
$rcsspthec = str_replace(‘ ‘,’ ‘,$rcstthec );
$rcsspthec = preg_replace( ‘|\[(.+?)\](.+?\[/\\1\])?|s’, ”, $rcsspthec );if(strlen($rcsspthec) > 155)
{
$newrcs=LimitText(trim($rcsspthec),10,155,””);
echo “<p>$newrcs”;
?>
<?php
}
else
{
$newrcs=$rcsspthec;
echo “<p>$newrcs”;
}
?>
…….
- The topic ‘Help With Excerpt’ is closed to new replies.