# Clearing the text from the shortcode

**URL:** <https://meta.discourse.org/t/clearing-the-text-from-the-shortcode/58036>\
**Category:** WordPress\
**Created:** [Fevereiro 27, 2017, 8:32pm 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:** 7

<div class="post-metadata">

**Author:** ![Del33t](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@Del33t](https://meta.discourse.org/u/Del33t)\
**Post date:** [Março 2, 2017, 10:11pm UTC](https://meta.discourse.org/t/clearing-the-text-from-the-shortcode/58036/7 "2017-03-02T22:11:20Z")

</div>

> [@simon](#):
>
> 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:
> 
> 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;
> 
> ```
> 
> }

You’re too helpful for your own good. Thank you!

---

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