Hiding Shortcodes in Feeds from WordPress Visual Composer

Im editing a WordPress theme that uses Visual Composer. On the homepage I am integrating my own custom news feed inside of Visual Composer.

I used the Insert-PHP plug-in to allow me to add PHP inside Visual Composer:

[insert_php]include('rm_news_feed.php');[/insert_php]

rm_news_feed.php:

<div class="vc_row wpb_row vc_row-fluid">
<div class="vc_col-sm-12 wpb_column vc_column_container ">

    <div class="wpb_wrapper">

        <div class="bg_parallax ">
            <div class="">
                <div class="vc_row wpb_row vc_inner vc_row-fluid">
                    <div class="inner-row clearfix">

                        <?php query_posts('cat=1&posts_per_page=3&orderby=desc'); ?>
                        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

                            <?php 
                            if(has_post_thumbnail($post->ID)){ 
                                $thumbsrc = get_the_post_thumbnail($post->ID,'medium');
                            }else{
                                $thumbsrc = "<img src="images/no_featured_image.jpg" alt="" . get_the_title() . "">";
                            }

                            ?>

                            <div class="vc_col-sm-4 wpb_column vc_column_container ">
                                <div class="wpb_wrapper">
                                    <article class="ts-service-style3 ">
                                        <a href="<?php the_permalink(); ?>"><figure><?php echo $thumbsrc; ?></figure></a>
                                        <a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a><p><?php the_excerpt(); ?></p>
                                    </article>
                                </div> 
                            </div>

                        <?php endwhile; endif; ?>
                        <?php wp_reset_query(); ?>

                    </div>
                </div>
            </div>
        </div>

    </div>

</div> 

My issue is that when this page outputs as soon as I use the_excerpt() it breaks the theme and displays a bunch of Visual Composer shortcodes. If I replace the_excerpt() with static text it works fine! But the second I switch it to the_excerpt() or the_content() all hell breaks loose.

I’ve tried:

$content = the_excerpt();
$content = preg_replace("/[(.*?)]/i", '', $content);
$content = strip_tags($content);

And that did nothing to remove the shortcodes.

What can I do here?


Source: shortcode

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.