daily pastebin goal
75%
SHARE
TWEET

Custom Excerpt - croque-pixel.com

a guest Dec 13th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Multiple Excerpt
  2. function croque_pixel_excerpt( $charlength, $excerpt = false, $excerpt_more = true ) {
  3.  
  4.     if( ! $excerpt) {
  5.         $excerpt = get_the_excerpt();
  6.     }
  7.  
  8.     // Remove shortcodes for excerpt
  9.     $excerpt = strip_shortcodes( $excerpt );
  10.     $charlength++;
  11.  
  12.     if( strlen( $excerpt ) > $charlength ) {
  13.         $subex   = substr( $excerpt, 0, $charlength-5 );
  14.         $exwords = explode(" ",$subex);
  15.         $excut   = -( strlen( $exwords[count( $exwords )-1] ) );
  16.         if( $excut < 0 ) {
  17.             $new_excerpt = substr( $subex, 0, $excut );
  18.         } else {
  19.             $new_excerpt = $subex;
  20.         }
  21.         if( true == $excerpt_more ) {
  22.             $new_excerpt .= "...";
  23.         }
  24.     } else {
  25.         $new_excerpt = $excerpt;
  26.     }
  27.  
  28.     return $new_excerpt;
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top