Last active
August 29, 2015 14:19
-
-
Save senlin/41dbe77976bc7dc99fd3 to your computer and use it in GitHub Desktop.
Issue with WordPress shortcodes
When I insert '[button]Button text[/button]' into a page, automatically <br /> tags comes before and after it, but I do not want that to happen. OP: https://www.linkedin.com/groups/Issue-WordPress-shortcodes-3722491.S.5993861951699058688
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WP Core function `shortcode_unautop` seems broken | |
* good hack is to replace the unwanted output | |
* | |
* @source: http://www.wpexplorer.com/clean-up-wordpress-shortcode-formatting/ | |
*/ | |
function so_remove_autop_shortcodes( $content ) { | |
$array = array ( | |
'<p>[' => '[', | |
']</p>' => ']', | |
']<br />' => ']' | |
); | |
$content = strtr( $content, $array ); | |
return $content; | |
} | |
add_filter( 'the_content', 'so_remove_autop_shortcodes' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment