brunopulis
5/3/2017 - 2:31 AM

get_excerpt

get_excerpt


/**
 * get_excerpt
 *
 * @param [type] $limit
 * @return void
 */
function excerpt( $limit ) {
  $excerpt = explode(' ', get_the_excerpt(), $limit );

  if ( count( $excerpt ) >= $limit ):
    array_pop( $excerpt );

    $excerpt = implode( " ",$excerpt ).'...';
  else:
    $excerpt = implode(" ",$excerpt);
  endif;

  $excerpt = preg_replace('`[[^]]*]`','',$excerpt);
  return $excerpt;
}