Last active
December 15, 2015 06:09
-
-
Save raphaelchaib/5213773 to your computer and use it in GitHub Desktop.
Wordpress: Custom excerpt size on any part of code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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