ControlledChaos
5/7/2015 - 8:32 AM

First Paragraph as an Excerpt

First Paragraph as an Excerpt

<?php

function ccd_custom_excerpt( $text, $raw_excerpt ) {
  
  if( ! $raw_excerpt ) {
    $content = apply_filters( 'the_content', get_the_content() );
    $text = substr( $content, 0, strpos( $content, '</p>' ) + 4 );
  }
  
  return $text;
}
add_filter( 'wp_trim_excerpt', 'ccd_custom_excerpt', 10, 2 );

?>

First Paragraph as an Excerpt

WordPress Snippet