Like others, I’m having issues with WP adding unwanted p tags in my code. I have a shortcode I created that is to simply just spit out my javascript and html when I use it. Everything works fine except WP is wraping each in p tags. Adding many lines of blank unwanted space.
I have tried the solution here: Automatically added brs and paragraphs?
to no avail. Here is what I have in my functions.php file
<?php
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);
remove_filter( 'the_excerpt', 'wpautop' );
/***************/
/**ShortCodes**/
/**************/
/*** Form to contact Us **/
function contact_us() {
return <<<HTML
<P> Here's the low down on what to do </p>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css"/>n
<link rel="stylesheet" href="http://studiocloud.com/css/validationEngine.jquery.css" type="text/css"/>n
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>n
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>n
<script src="http://cloudforms.co/js/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>n
<script src="http://cloudforms.co/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>n
<script type="text/javascript" src="http://cloudforms.co/js/html5placeholder.jquery.js"></script>n
<form action="" id="signupform" name="signupform">
<input type="hidden" id="tid" name="tid" value=""/>
<input type="hidden" id="scid" name="scid" value="TPN02L48KAVJKVRD"/>
<input type="hidden" id="fid" name="fid" value="392"/>
<div class="box" >
<fieldset class="field_set""><legend>Contact Us For More Information</legend>
<label><span>First Name *</span><input type="text" id="firstName" name="firstName" class="validate[required] input_text" placeholder="First Name" ></label>
<label><span>Last Name *</span><input type="text" id="lastName" name="lastName" class="validate[required] input_text" placeholder="Last Name" ></label>
<label><span>Phone</span><input type="text" id="workPhone" name="workPhone" class="validate[optional] input_text" placeholder="Phone" ></label>
<label><span>Email *</span><input type="text" id="email" name="email" class="validate[required,custom[email]] input_text" placeholder="Email" ></label>
<label><span>Comments *</span><textarea name="item5" id="item5" class="message" placeholder="Comments" ></textarea></label>
<label><span></span>* Required Fields</label>
<label><input type="button" id="item7" name="item7" onClick="processContactUs(event)" class="button" value="Submit" ></label>
</fieldset>
</div>
</form>
<div class="modal"><!-- Place at bottom of page --></div>
HTML;
}
add_shortcode('contact_us','contact_us');
any ideas? using n seems to get rid of unwanted br tags I was getting, but now still getting the p tags.
thanks.
The simple solution is to not give
wpautop
anything to chew on.Your generated code won’t be formatted, but there is no reason it should be. We are long past the days of static HTML, at least I am ( “Thank you” to the Lords of Kobol ), where such formatting mattered. Now, all that formatted is just unnecessary characters that have to travel down the wire.
Re-arranging the default WP filters may have unwanted consequences (I’ve had some issues with some plugins that generated forms via shortcodes when using this method). What works perfectly for me (and many others) is this solution: