Remove visual composer shortcodes from content in wordpress


<?php
/* Get only listed posts */
$test_array = array(‘335’, ‘328’, ‘970’);

$query = new WP_Query( array( ‘post_type’ => ‘testimonials’, ‘post__in’ => $test_array ) );

global $post;

/* Get Post url */
$page_url = get_permalink($post->ID);

/* Get Post congtent */
$content = $post->post_content;

/* Remove visual composer shortcode like [vc_row] link that */
$desc = strip_tags(do_shortcode($post->post_content));

/* Remove empty spaces */
$desc = trim(preg_replace(‘/\s+/’,’ ‘, $desc ));

/* Get content with limit */
$desc = mb_strimwidth($desc, 0, 200, ‘…’);

?>

Advertisements

4 Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s