Skip to content

Instantly share code, notes, and snippets.

@yratof
Created April 21, 2016 08:27
Show Gist options
  • Save yratof/8e1cb96c5bdc14e439ad5cadde263b98 to your computer and use it in GitHub Desktop.
Save yratof/8e1cb96c5bdc14e439ad5cadde263b98 to your computer and use it in GitHub Desktop.
Visual Composer and Relevanssi showing shortcodes in search
<?php
// Issue with showing VC shortcodes in search results
// Strip out Visual Composer specific shortcodes
add_filter('relevanssi_pre_excerpt_content', 'rlv_trim_vc_shortcodes');
function rlv_trim_vc_shortcodes($content) {
$content = preg_replace('/\[\/?vc_.*?\]/', '', $content);
return $content;
}
@Sarfarazsajjad
Copy link

in which file should this be added

@tokyobear
Copy link

Thanks!

@ituk
Copy link

ituk commented Oct 16, 2017

exactly what i needed! thanks!

@msaari
Copy link

msaari commented Sep 25, 2018

This is currently unnecessary, Relevanssi does this automatically now.

@razorfrog
Copy link

Still helpful to hide other particular shortcodes though by replacing the "vc_" text. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment