Advertisement
darrenbachan

Untitled

Jun 4th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. // Grab First Paragraph Of Text And Ignore Images For Excerpt
  2.     function awesome_excerpt($text, $raw_excerpt) {
  3.         if( ! $raw_excerpt ) {
  4.             $content = apply_filters( 'the_content', get_the_content() );
  5.             $text = substr( $content, 0, strpos( $content, '</p>' ) + 4 );
  6.         }
  7.         $text = preg_replace("/<img[^>]+\>/i", "", $text);
  8.         return $text;
  9.     }
  10.     add_filter( 'wp_trim_excerpt', 'awesome_excerpt', 10, 2 );
  11.  
  12.     // Customize Excerpt Word Count Length
  13.     function custom_excerpt_length() {
  14.         return 25;
  15.     }
  16.     add_filter('excerpt_length', 'custom_excerpt_length', 999);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement