Thursday, 27 October 2016

How to Remove Visual Composer's shortcodes from the Post Content ?




As we need to remove Visual Composer's shortcodes from the Post Content , we need to follow the below steps -

1. put the following code in functions.php

functions.php
function get_the_post_content($postdata='')
{
$postdata1 = strip_tags(do_shortcode($postdata));
$postdata1 = trim(preg_replace('/\s+/',' ', $postdata1 ));
return $postdata1;
}


2. you can get the post content on any page by integrating the below code
page.php


<?php if( have_posts() ):

         while( have_posts() ): the_post();
         the_title(); // showing post title

echo get_the_post_content($post->post_content); // post content

or

echo get_the_post_content(get_the_content()); // post content

endwhile;
 endif; wp_reset_query(); ?>