Created
November 26, 2019 17:17
-
-
Save thecodepoetry/b17c1e74bbe377b8091a74d2b63430a7 to your computer and use it in GitHub Desktop.
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
function the7_shortcodeaware_excerpt_filter( $output ) { | |
global $post; | |
if ( empty( $output ) && ! empty( $post->post_content ) ) { | |
add_filter( 'strip_shortcodes_tagnames', 'the7_shortcodes_to_strip_from_auto_exerpt' ); | |
add_filter( 'strip_shortcodes_tagnames', 'rcb_shortcodes_to_strip_from_auto_exerpt' ); | |
$content = strip_shortcodes( $post->post_content ); | |
remove_filter( 'strip_shortcodes_tagnames', 'the7_shortcodes_to_strip_from_auto_exerpt' ); | |
remove_filter( 'strip_shortcodes_tagnames', 'rcb_shortcodes_to_strip_from_auto_exerpt' ); | |
$text = wp_strip_all_tags( do_shortcode( $content ) ); | |
$excerpt_length = apply_filters( 'excerpt_length', 55 ); | |
$excerpt_more = apply_filters( 'excerpt_more', ' [...]' ); | |
return wp_trim_words( $text, $excerpt_length, $excerpt_more ); | |
} | |
return $output; | |
} | |
function rcb_shortcodes_to_strip_from_auto_exerpt() { | |
return array('rcblock'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment