Hi storeapps,
Yes, I saw that the default for the_excerpt is 50 words. The post text is not always the same length. That’s why I look for a different solution. There is one client who has a recipe website. He starts with the recipe intro and after that the ingredients. He wants only to send the intro part. With the_excerpt he’ll get some of the ingredients in the email which doesn’t look nice.
I understand that the_excerpt will work for most people, because they don’t use the more tag. But for the ones that use the more tag a keyword like ###POSTMORETAG### would be great ??
Something like this?
// Get post excerpt
$the_excerpt = $post->post_content;
$the_excerpt = strip_tags(strip_shortcodes($the_excerpt));
$words = explode(‘ ‘, $the_excerpt, $excerpt_length + 1);
if(count($words) > $excerpt_length)
{
array_pop($words);
array_push($words, ‘…’);
$the_excerpt = implode(‘ ‘, $words);
}
// Get post until more tag
$text_until_more_tag = get_extended ($post->post_content);
$until_more_tag = $text_until_more_tag[‘main’];
$until_more_tag = strip_tags(strip_shortcodes($until_more_tag));
if ( (function_exists(‘has_post_thumbnail’)) && (has_post_thumbnail($post_id)) )
{
$post_thumbnail = get_the_post_thumbnail($post_id, ‘full’);
}
if($post_thumbnail <> “”)
{
$post_thumbnail_link = ““.$post_thumbnail.”“;
}
$content = str_replace(‘###POSTLINK-ONLY###’, $post_link, $content);
if($post_link <> “”)
{
$post_link_with_title = ““.$post_title.”“;
$content = str_replace(‘###POSTLINK-WITHTITLE###’, $post_link_with_title, $content);
$post_link = ““.$post_link.”“;
}
$content = str_replace(‘###POSTTITLE###’, $post_title, $content);
$content = str_replace(‘###POSTLINK###’, $post_link, $content);
$content = str_replace(‘###POSTIMAGE###’, $post_thumbnail_link, $content);
$content = str_replace(‘###POSTDESC###’, $the_excerpt, $content);
$content = str_replace(‘###POSTMORETAG###’, $until_more_tag, $content);
$content = str_replace(‘###POSTFULL###’, $post_full, $content);
$content = str_replace(‘###DATE###’, $post_date, $content);
break;
Thank you for pointing out ###POSTFULL###. Might come in handy one day.