# Clearing the text from the shortcode

**URL:** <https://meta.discourse.org/t/clearing-the-text-from-the-shortcode/58036>\
**Category:** WordPress\
**Created:** [27 Febrero, 2017 20:32 UTC](https://meta.discourse.org/t/clearing-the-text-from-the-shortcode/58036 "2017-02-27T20:32:32Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [1 Marzo, 2017 20:52 UTC](https://meta.discourse.org/t/clearing-the-text-from-the-shortcode/58036/6 "2017-03-01T20:52:36Z")

</div>

Yes, that’s the right idea, but you can do that in your `functions.php` file without having to alter the plugin. That way you won’t need to alter the plugin every time it’s updated.

Look for this line just before you’ve made those changes:  
`$excerpt = apply_filters( 'wp_discourse_excerpt', $raw );`

This lets you create a function in your `functions.php` file that will be passed the raw content of your post. Something like this should work:

```plaintext
add_filter( 'wp_discourse_excerpt', 'my_namespace_fix_shortcodes' );

function my_namespace_fix_shortcodes( $excerpt ) {
    $excerpt = str_replace( '[nk_title]', '<h2>', $excerpt );
    $excerpt = str_replace( '[/nk_title]', '</h2>', $excerpt ); 
    $excerpt = str_replace( '[yp_text]', '<p>', $excerpt );
    $excerpt = str_replace( '[/yp_text]', '</p>', $excerpt );

    $excerpt = preg_replace('(\\[([^[]|)*])', '', $excerpt );

    return $excerpt;
}

```

---

_[View the full topic](https://meta.discourse.org/t/clearing-the-text-from-the-shortcode/58036)._
