Site logo

Archived topic

Custom Excerpt Function Help?

1 reply · Started by Daniel on January 17, 2017

Viewing posts 1–2 of 2

I am using a custom function to grab text from the content, so that I don't have to fill in the excerpt field. I am mainly using this for custom post types.
It is working, but I can't seem to overwrite GP's read more link.
Function below:

function get_excerpt(){
$excerpt = get_the_content();
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, 120);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
$excerpt = '<p>'.$excerpt.'... More</p>';
return $excerpt;
}

This archived topic is closed to new replies.