Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Last active December 15, 2015 06:09
Show Gist options
  • Save raphaelchaib/5213773 to your computer and use it in GitHub Desktop.
Save raphaelchaib/5213773 to your computer and use it in GitHub Desktop.
Wordpress: Custom excerpt size on any part of code
<?php
function custom_excerpt($new_length = 20, $new_more = '...') {
add_filter('excerpt_length', function () use ($new_length) {
return $new_length;
}, 999);
add_filter('excerpt_more', function () use ($new_more) {
return $new_more;
});
$output = get_the_excerpt();
$output = apply_filters('wptexturize', $output);
$output = apply_filters('convert_chars', $output);
$output = '<p>' . $output . '</p>';
echo $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment