Skip to content

Instantly share code, notes, and snippets.

@cabans
Last active November 18, 2015 16:46
Show Gist options
  • Save cabans/5d41733dd817a21e2ff7 to your computer and use it in GitHub Desktop.
Save cabans/5d41733dd817a21e2ff7 to your computer and use it in GitHub Desktop.
WordPress - Clean paragraphs in Shortcodes
<?php
// Move priority of Auto Paragraph function
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);
// Shortcode function
function shortcode_function( $atts, $content ) {
// Clean spaces and add paragraphs
$content = wpautop(trim($content));
return $content;
}
add_shortcode( 'no-paragraphs', 'shortcode_function' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment