Limit the_excerpt in the first point (.) of the sentence

I would like to filter the function the_excerpt to stop to find the first endpoint.

Ex: “This is the article summary which ends at the endpoint with a full-stop.”

Any idea is welcome.

1 Answer
1

First, please make sure you understand the difference between the_excerpt and the_content. You are asking about the_excerpt but I suspect that you might actually mean the_content. That said…

You can filter the the_excerpt function with a filter of the same name.

add_filter(
  'the_excerpt',
  function ($excerpt) {
    return substr($excerpt,0,strpos($excerpt,'.')+1);
  }
);

Leave a Comment