WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

Try to modify your shortcode function to output your form - I mean insert your form html to $output varible of your code:

function raw_shortcode( $atts ) {
    $output = '<form><label for="id">Label</label><input type="text" name="name" id="id"/></form>';
    return $output;
add_shortcode('form', 'raw_shortcode');

And than just add [form] to your content.

share|improve this answer
Yeah, I thought of that, and might even end up doing it. But it seems ugly, as it separates the form content from the context of the page where it's supposed to appear. – Miral Jan 31 '13 at 21:40
Any solution? I'm looking for a way to put code in articles/pages that is not modified by WP – Olivier Pons Nov 25 '13 at 9:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.