# Clearing the text from the shortcode

**URL:** https://meta.discourse.org/t/clearing-the-text-from-the-shortcode/58036
**Category:** WordPress
**Created:** [27 Febbraio 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:** 2

<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: [27 Febbraio 2017, 9:32pm UTC](https://meta.discourse.org/t/clearing-the-text-from-the-shortcode/58036/2 "2017-02-27T21:32:32Z")

</div>

I’m assuming those shortcodes are being added by the Visual Composer plugin. I’ve tried a few things for dealing with them. There are three different approaches in the ‘Dealing with WordPress shortcodes’ section of this topic: [WP Discourse plugin tips and tricks](https://meta.discourse.org/t/wp-discourse-plugin-tips-and-tricks/50757)

From what I remember, with Visual Composer shortcodes, calling `do_shortcode` doesn’t work. The shortcode is processed, but a bunch of whitespace is added to the markup and it gets interpreted as code by Discourse.

If you need to have the content of the shortcodes published to Discourse, probably the first approach in that topic would be the best. If it’s not giving you the formatting that you need, the regular expression could be improved so that it replaces certain shortcodes with `<div></div>` tags.

```plaintext
// Removes anything that looks like a shortcode. This will remove anything in the post that
// occurs inside of brackets `[...]`.
// Replace 'my_namespace' with your namespace.
add_filter( 'wp_discourse_excerpt', 'my_namespace_remove_shortcodes' );
function my_namespace_remove_shortcodes( $excerpt ) {
    $excerpt = preg_replace( '/\[.*\]/', '', $excerpt );

    return $excerpt;
}

```

---

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