Using WordPress 3.5.

I’m trying to put a <form> into a Page of a WP-based site. Unfortunately, WP is “helpfully” screwing up the formatting of the form by inserting <br> and <p> tags in inappropriate places next to the form controls.

I don’t want to disable wpautop globally, as it’s still helpful for blog posts (particularly as this is a multi-author site). I don’t even want to disable it for the whole of the page. I want some way to disable it only in this one specific section of this one page.

I read in the WP changelogs that supposedly shortcodes do not run wpautop on their output any more, so I tried creating the following shortcode:

function raw_shortcode( $atts, $content = null ) {
   return $content;
}
add_shortcode('raw', 'raw_shortcode');

Unfortunately this does not appear to work — surrounding the form with this still results in undesirable breaks and paragraphs being added.

I’ve seen a few examples suggesting a modification to the standard filters, but I’ve also read some other pages that suggest this is a bad idea.

2 Answers
2

Late to the party, but this plugin, Toggle wpautop, lets you selectively disable whether you want WP to butcher your content on pages or posts, and works on WP 4.9 (current version as of this answer).

Leave a Reply

Your email address will not be published. Required fields are marked *