Created
August 16, 2013 09:56
-
-
Save rfvcorreia/6248642 to your computer and use it in GitHub Desktop.
Remove Shortcodes from excerpt
This file contains hidden or 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
| function custom_excerpt($text = '') { | |
| $raw_excerpt = $text; | |
| if ( '' == $text ) { | |
| $text = get_the_content(''); | |
| $text = strip_shortcodes( $text ); | |
| $excerpt_length = apply_filters('excerpt_length', 50); | |
| $excerpt_more = apply_filters('excerpt_more', ' ' . '...'); | |
| $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); | |
| } | |
| return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); | |
| } | |
| remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' ); | |
| add_filter( 'get_the_excerpt', 'custom_excerpt' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment