Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save nextab/e2a2cdcc00d2086488e326cd7804bc45 to your computer and use it in GitHub Desktop.

Select an option

Save nextab/e2a2cdcc00d2086488e326cd7804bc45 to your computer and use it in GitHub Desktop.
#region Render Shortcodes inside Divi Modules
add_filter( 'do_shortcode_tag','nxt_filter_shortcode_output',10,3);
function nxt_filter_shortcode_output($output, $tag, $attr){
$allowed_shortcodes = [
'et_pb_button',
'et_pb_accordion',
'et_pb_toggle',
'et_pb_cta',
];
if(!in_array($tag, $allowed_shortcodes)){ //make sure it is the right shortcode
return $output;
}
// Bring back opening brackets
$output = str_replace("[", "[", str_replace("[", "[", $output));
$output = str_replace("]", "]", str_replace("]", "]", $output));
// Render output with shortcodes
return do_shortcode($output);
}
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment