[wp-hackers] Shortcodes and formatting

Aaron D. Campbell aaron at xavisys.com
Mon Mar 31 15:37:43 GMT 2008


I've moved on to 2.5, and I'm quite happy with a lot of the new stuff 
that's going on with the plugin API, especially shortcodes.  HOWEVER, it 
seems that if I replace a shortcode with something (like a form for 
instance), WP is trying to format it, inserting a bunch of tags where 
they DO NOT BELONG.  Is there a way to run these shortcodes 
post-formatting?  I want to use shortcodes to add a google Map with a 
small form under it.  Here is how it should look:

<div id='map_{$this->mapNum}' style='width:{$mapInfo->width}; 
height:{$mapInfo->height};'></div>
<form action="" onsubmit="return wpGMaps.getDirections(this);">
    <fieldset>
        <legend>Get Directions:</legend>
        <label for="saddr_{$this->mapNum}">Start address:</label>
        <input type="text" name="saddr" id="saddr_{$this->mapNum}" 
value="" /><br />
        <input value="Get Directions" type="submit" />
        <input type="hidden" name="mapNum" value="{$this->mapNum}" />
        <input type="hidden" name="daddr" id="daddr_{$this->mapNum}" 
value="{$mapInfo->name}@{$mapInfo->address}" />
    </fieldset>
</form>
<div id='dir_{$this->mapNum}'></div>

but I get:
<div id='map_1' style='width:100%; height:400;'></div>
<form action="" onsubmit="return wpGMaps.getDirections(this);">
    <fieldset><br />
        <legend>Get Directions:</legend><br />
        <label for="saddr_1">Start address:</label></p>

<input type="text" name="saddr" id="saddr_1" value="" /></p>
<input value="Get Directions" type="submit" />
<input type="hidden" name="mapNum" value="1" />
<input type="hidden" name="daddr" id="daddr_1" value="Aero Rental - 
Phoenix at 3432 W. Clarendon, 85017" />
    </fieldset><br />
</form>
<div id='dir_1'></div>

As you can see, it added a bunch of closing paragraph tags (with no 
opening tags to match), as well as a bunch of <br /> tags that I don't want.


More information about the wp-hackers mailing list