Skip to content

Instantly share code, notes, and snippets.

@ingozoell
Created September 27, 2017 09:54
Show Gist options
  • Save ingozoell/73687e7db3c90a7f29543ab6d3ebffb8 to your computer and use it in GitHub Desktop.
Save ingozoell/73687e7db3c90a7f29543ab6d3ebffb8 to your computer and use it in GitHub Desktop.
// REMOVE P from shortcodes // https://gist.github.com/bitfade/4555047
function the_content_filter($content) {
// array of custom shortcodes requiring the fix
$block = join("|",array("iz_mehr","iz_col", "text_platzhalter"));
// opening tag
$rep = preg_replace("/(<p>)?\[($block)(\s[^\]]+)?\](<\/p>|<br \/>)?/","[$2$3]",$content);
// closing tag
$rep = preg_replace("/(<p>)?\[\/($block)](<\/p>|<br \/>)?/","[/$2]",$rep);
return $rep;
}
add_filter("the_content", "the_content_filter");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment