Wraping $content into link with shortcodes

This is a filter in WordPress called wpautop it is there to make formatting cleaner when publising posts, however when you want more control over formatting it can be a pain. It basically wraps returns in paragraphs so that the space you see in the editor is obeyed on the front end.

You can disable it completely by placing this in your functions.php

remove_filter( 'the_content', 'wpautop' );

Or you can disable it for only elements wrapped in a shortcode by placing this in your functions.php which will delay the formatting until after shortcodes are rendered. This is what the 12 means in the add_filter call – it basically says do this as your 12th process as shortcodes may be executed at the 6th process for example

remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);

You can read more about the auto formatting at the codex here: http://codex.wordpress.org/Function_Reference/wpautop

Leave a Comment