Skip to content

Instantly share code, notes, and snippets.

@setuix
Created December 15, 2014 06:50
Show Gist options
  • Save setuix/075503610e09345e8df0 to your computer and use it in GitHub Desktop.
Save setuix/075503610e09345e8df0 to your computer and use it in GitHub Desktop.
<?php add_filter('the_excerpt', 'my_excerpts');
function my_excerpts($content = false) {
global $post;
$mycontent = $post->post_excerpt;
$mycontent = $post->post_content;
$mycontent = strip_shortcodes($mycontent);
$mycontent = str_replace(']]>', ']]&gt;',$mycontent);
$mycontent = strip_tags($mycontent);
$excerpt_length = 55;
$words = explode(' ', $mycontent,$excerpt_length + 1);
if(count($words) > $excerpt_length) :
array_pop($words);
array_push($words, '...');
$mycontent = implode(' ', $words);
endif;
$mycontent = '<p>' . $mycontent . '</p>';
// Make sure to return the content
return $mycontent;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment