WordPress.org

Support

Support » Plugins and Hacks » Column Shortcodes » [Resolved] [Plugin: Column Shortcodes] Using plugin removes Excerpts

[Resolved] [Plugin: Column Shortcodes] Using plugin removes Excerpts

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Codepress

    @codepress

    This is the default way on how WordPress handles the excerpt. It will always strip out the shortcodes.

    I modified the excerpt function for you so you it will leave the shortcodes in place when using the excerpt. Just place this code in your functions.php:

    /**
     *  Trim the excerpt with shortcodes
     *
     */
    function wp_trim_excerpt_with_shortcodes($text = '')
    {
    	$raw_excerpt = $text;
    	if ( '' == $text ) {
    		$text = get_the_content('');
    		$text = apply_filters('the_content', $text);
    		$text = str_replace(']]>', ']]>', $text);
    		$excerpt_length = apply_filters('excerpt_length', 55);
    		$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', 'wp_trim_excerpt_with_shortcodes' );

    Let me know if this works for you.

    Hi.
    Thanks for the code – not very confident with PHP, but will give it a try.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] [Plugin: Column Shortcodes] Using plugin removes Excerpts’ is closed to new replies.
Skip to toolbar