Remove Shortcode […] from Blog Preview

When utilizing shortcode (plugin, etc.) near the top of the page, the plugin shortcode displays in the preview. Is there a way to hide text within brackets from a preview on a recent posts type of page?

The following example shows the shortcode within a blog post preview:

Example of Brackets within Preview

4 Answers
4

You can do with PHP. Just remove part where is get_content() and add this:

<?php 
            $content=get_the_content();
            $content = preg_replace('#\[[^\]]+\]#', '',$content);
            echo apply_filters('the_content', $content);
        ?>

That is regular expression added inside content. This regex will remove all tags inside content.

Leave a Comment