Answers.Body: <p>Ok, I figured it out. Here's the auto-relevant bits from <code>functions.php</code>:</p>
  
  <pre><code>function better_wpautop($pee){
      return wpautop( $pee, $br=0 );
  }
  
  /* This is a hack to make sure that wordpress's autop filter doesn't apply to shortcodes */
  remove_filter( 'the_content', 'wpautop' );
  add_filter( 'the_content', 'better_wpautop', 11 );
  add_filter( 'the_content', 'shortcode_unautop', 12 );
  </code></pre>
  
  <p>I thought <code>shortcode_unautop</code> was supposed to fix this, but I took a look at it and it's a huge hack that tries to strip p tags back out of shortcode content in a truly terrifying way with a regex (<a href="https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags">ob Zalgo reference</a>). So I made a copy of my standard page template and added the following to the top:</p>
  
  <pre><code>remove_filter( 'the_content', 'better_wpautop', 11 );
  remove_filter( 'the_content', 'shortcode_unautop', 12 );
  </code></pre>
  
  <p>Now there is nothing autop related happening, which is fine, since the entire content of the page comes from the CiviCRM profile.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-09T19:21:52.067Z
Answers.Text: Just want to check- was the issue in your local site?   I just checked a few of ours and I am not getting any random <p> tags
Answers.UserDisplayName: Kevin Cristiano
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-09T21:53:43.803Z
Answers.Text: @KevinCristiano - I wouldn't be surprised if it was specific to how autop was configured on my site. That said, the config I used (with the altered filter stack) is recommended in various places where people have discussed issues with the WP autop feature, so I wouldn't be surprised if someone else encountered it.
Answers.UserDisplayName: Dave Rolsky
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-09T21:54:14.853Z
Answers.Text: @KevinCristiano - argh, hit enter too soon. I think it'd be nice if CiviCRM could disable autop for the content that it generates somehow. I don't know if that's possible.
Answers.UserDisplayName: Dave Rolsky
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-09T18:43:42.510Z
Answers.LastActivityDate: 2016-06-09T18:43:42.510Z
Answers.LastEditDate: 2017-05-23T12:38:59.763Z
Answers.UserDisplayName: Dave Rolsky
Body: <p>Even though I have disabled autop for shortcodes, I end up with a lot of 
  extra <code>&lt;p&gt;</code> tags in the generated form. Here's a snippet:</p>
  
  <pre><code>&lt;div id="editrow-email-Primary" class="crm-section editrow_email-Primary-section form-item"&gt;
    &lt;div class="label"&gt;
      &lt;label for="email-Primary"&gt; Email
        &lt;span lass="crm-marker" title="This field is required."&gt;*&lt;/span&gt;
  &lt;/p&gt;&lt;p&gt;
      &lt;/label&gt;
    &lt;/div&gt;
    &lt;div class="edit-value content"&gt;
      &lt;input maxlength="254" size="30" name="email-Primary" type="text" id="email-Primary" class="big crm-form-text required" /&gt;
    &lt;/div&gt;
  &lt;div class="clear"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Note the stray <code>&lt;/p&gt;&lt;p&gt;</code> in the middle. But while a bit wrong, this is ok. What's really a problem is that the generated JS code for the datepicker <em>also</em> gets a bunch of random <code>&lt;p&gt;</code> tags:</p>
  
  <p><code>&lt;script type="text/javascript"&gt;/*&lt;![CDATA[*/&lt;/p&gt;&lt;p&gt;CRM.$(function($){&lt;/p&gt;&lt;p&gt;var $dateElement=$('input[name=birth_date_display_57599e0ccbe99].dateplugin:not(.hasDatepicker)');&lt;/p&gt;&lt;p&gt;
  </code></p>
  
  <p>This completely breaks the JS.</p>
  
  <p>Any hints on how to figure out where these tags are coming from would be helpful. This sure looks like autop acting up, but I don't see how it could affect the shortcode's generated <em>content</em>, even when it might wrap the shortcode itself.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-09T18:01:34.053Z
Comments.Text: What CiviCRM version? Also have you tried switching to the default Wordpress theme?
Comments.UserDisplayName: Andrei
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-09T21:55:31.853Z
Comments.Text: @Andrei - thanks for the response. I'm sure it was specific to my theme (see my answer below).
Comments.UserDisplayName: Dave Rolsky
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-09T22:09:20.180Z
Comments.Text: @autarch glad you figured it out. Voted up. What theme are you using, just to be aware in the future.
Comments.UserDisplayName: Andrei
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-10T03:20:36.027Z
Comments.Text: @Andre - it's a customized theme based off The Bootstrap theme.
Comments.UserDisplayName: Dave Rolsky
Tags: <wordpress>
Title: Extra p tags in profile form inserted via WP shortcode
ThreadText: # Extra p tags in profile form inserted via WP shortcode
  
  (Asked by: username_0 on 2016-06-09)
  
  Even though I have disabled autop for shortcodes, I end up with a lot of 
  extra  tags in the generated form. Here's a snippet:
  
    
       Email
        *
  
      
    
    
      
    
  
  
  Note the stray  in the middle. But while a bit wrong, this is ok. What's really a problem is that the generated JS code for the datepicker also gets a bunch of random  tags:
  
  **Tags:** wordpress
  
  > **Comments:**
  > **username_1**: What CiviCRM version? Also have you tried switching to the default Wordpress theme?  
  > **username_0**: @username_1 - thanks for the response. I'm sure it was specific to my theme (see my answer below).  
  > **username_1**: @autarch glad you figured it out. Voted up. What theme are you using, just to be aware in the future.  
  > **username_0**: @Andre - it's a customized theme based off The Bootstrap theme.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-06-09. Score: 1
  
  Ok, I figured it out. Here's the auto-relevant bits from functions.php:
  function better_wpautop($pee){
      return wpautop( $pee, $br=0 );
  }
  
  /* This is a hack to make sure that wordpress's autop filter doesn't apply to shortcodes */
  remove_filter( 'the_content', 'wpautop' );
  add_filter( 'the_content', 'better_wpautop', 11 );
  add_filter( 'the_content', 'shortcode_unautop', 12 );
  
  I thought shortcode_unautop was supposed to fix this, but I took a look at it and it's a huge hack that tries to strip p tags back out of shortcode content in a truly terrifying way with a regex (ob Zalgo reference). So I made a copy of my standard page template and added the following to the top:
  remove_filter( 'the_content', 'better_wpautop', 11 );
  remove_filter( 'the_content', 'shortcode_unautop', 12 );
  
  Now there is nothing autop related happening, which is fine, since the entire content of the page comes from the CiviCRM profile.
  
  > **Comments:**
  > **username_2**: Just want to check- was the issue in your local site?   I just checked a few of ours and I am not getting any random <p> tags  
  > **username_0**: @KevinCristiano - I wouldn't be surprised if it was specific to how autop was configured on my site. That said, the config I used (with the altered filter stack) is recommended in various places where people have discussed issues with the WP autop feature, so I wouldn't be surprised if someone else encountered it.  
  > **username_0**: @KevinCristiano - argh, hit enter too soon. I think it'd be nice if CiviCRM could disable autop for the content that it generates somehow. I don't know if that's possible.  
  
  ---
  
  