If you are using Visual Composer to create your content in WordPress you may find the used shortcodes in your campaign.
By default Mailster will strip shortcodes but stripping those shortcodes would cause stripping of the actual content as well. The get rid of the shortcodes in your campaign you have to add a custom snippet to your theme functions.php.
Dynamic Method
add_filter( 'mailster_replace_post_content', 'mailster_replace_VC_shortcodes_dynamic', 10 , 3 );
add_filter( 'mailster_replace_post_excerpt', 'mailster_replace_VC_shortcodes_dynamic', 10 , 3 );
function mailster_replace_VC_shortcodes_dynamic( $replace_to, $post, $extra = null ) {
$shotcodes_tags = array( 'vc_row', 'vc_column', 'vc_column', 'vc_column_text', 'vc_message' );
$replace_to = preg_replace( '/\[(\/?(' . implode( '|', $shotcodes_tags ) . ').*?(?=\]))\]/', ' ', $replace_to );
return $replace_to;
}
This will remove shortcodes on dynamic tags like {post_content:-1}
. If you have a custom post type where you use Visual Composer you need to add the filter to this post type as well:
add_filter( 'mailster_replace_MY-CUSTOM-POSTTYPE_content', 'mailster_replace_VC_shortcodes_dynamic', 10 , 3 );
(replace “MY-CUSTOM-POSTTYPE” with your actual post type name).
Static Method
To remove the shortcodes on a static post use this snippet:
add_filter( 'mailster_auto_post', 'mailster_replace_VC_shortcodes_static', 10, 2 );
function mailster_replace_VC_shortcodes_static( $data, $post ) {
if ( isset( $data['content'] ) ) {
$data['content'] = mailster_replace_VC_shortcodes_dynamic( $data['content'], $post );
}
if ( isset( $data['excerpt'] ) ) {
$data['excerpt'] = mailster_replace_VC_shortcodes_dynamic( $data['content'], $post );
}
return $data;
}
This will only work for Visual Composer but if you are using another page builder which uses shortcodes you just have to replace the $shotcodes_tags array with the shortcodes you like to remove.