Skip to content

Instantly share code, notes, and snippets.

@ramzesimus
Created June 26, 2013 11:52
Show Gist options
  • Save ramzesimus/5866833 to your computer and use it in GitHub Desktop.
Save ramzesimus/5866833 to your computer and use it in GitHub Desktop.
<?php
add_filter("the_content", "the_content_filter");
function the_content_filter($content) {
// array of custom shortcodes requiring the fix
$block = join("|",array("col","shortcode2","shortcode3"));
// 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment