Title: Shortcode in Exceprt
Last modified: August 22, 2016

---

# Shortcode in Exceprt

 *  [streamworksaudio](https://wordpress.org/support/users/streamworksaudio/)
 * (@streamworksaudio)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-exceprt/)
 * I was wondering if there is some way to remove shortcodes from showing up in 
   the post excerpts?
 * Some of my posts have a shortcode near the start of the post, and when I look
   at the archive pages to lost the posts I can see the raw shortcode in the excerpt.
   I would like to be able to not have that shown.
 * Any ideas?
 * Cheers

Viewing 1 replies (of 1 total)

 *  [bdbrown](https://wordpress.org/support/users/bdbrown/)
 * (@bdbrown)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-exceprt/#post-5728736)
 * Hi streamworksaudio. Don’t know if this is exactly addresses your issue but you
   might try adding this to a child theme functions.php file:
 *     ```
       /* Default WP process stirps shortcodes and tags from post content. That also removes the embedded shortcode text so, if the post doesn't have an excerpt, the excerpt that is automatically-generated from the post content is then missing the text that was in the shortcode. Override this process and remove the shortcode but retain the embedded text.
       */
       function my_custom_excerpt($text = '') {
       	$raw_excerpt = $text;
       	if ( '' == $text ) {
       		$text = get_the_content('');
       		// $text = strip_shortcodes( $text );
       		$text = do_shortcode( $text );
       		$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', 'my_custom_excerpt'  );
       ```
   
 * If that doesn’t work here are a couple of other posts that might help:
    [https://wordpress.org/support/topic/stripping-shortcodes-keeping-the-content?replies=16](https://wordpress.org/support/topic/stripping-shortcodes-keeping-the-content?replies=16)
   [https://wordpress.org/support/topic/shortcodes-dont-work-in-excerpts?replies=9](https://wordpress.org/support/topic/shortcodes-dont-work-in-excerpts?replies=9)

Viewing 1 replies (of 1 total)

The topic ‘Shortcode in Exceprt’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/hueman/3.7.27/screenshot.png)
 * Hueman
 * [Support Threads](https://wordpress.org/support/theme/hueman/)
 * [Active Topics](https://wordpress.org/support/theme/hueman/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/hueman/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/hueman/reviews/)

## Tags

 * [excerpt](https://wordpress.org/support/topic-tag/excerpt/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 1 reply
 * 2 participants
 * Last reply from: [bdbrown](https://wordpress.org/support/users/bdbrown/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-exceprt/#post-5728736)
 * Status: not resolved