Skip to content

Instantly share code, notes, and snippets.

@brunopulis
Created May 3, 2017 02:32
Show Gist options
  • Save brunopulis/9234f153ded37ca089c71ed26a31a723 to your computer and use it in GitHub Desktop.
Save brunopulis/9234f153ded37ca089c71ed26a31a723 to your computer and use it in GitHub Desktop.
get_content
/**
* content
*
* Limit the size of text
*
* @param int $limit quantity to excerpt
* @return void
*/
function content($limit) {
$content = explode(' ', get_the_content(), $limit);
if ( count( $content ) >= $limit ):
array_pop($content);
$content = implode(" ",$content).'...';
else:
$content = implode(" ",$content);
endif;
$content = preg_replace('/[.+]/','', $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment