Title: Inserting own scriptingcode at a post
Last modified: August 18, 2016

---

# Inserting own scriptingcode at a post

 *  [maximus43](https://wordpress.org/support/users/maximus43/)
 * (@maximus43)
 * [19 years, 5 months ago](https://wordpress.org/support/topic/inserting-own-scriptingcode-at-a-post/)
 * Hi,
    I want to at some special code in my post, so I used the ‘edit html source’
   option, where I pasted my code. It is code to show a gmapez google map, with 
   some own modified lightbox-script (so I could not use a default plugin). Now 
   this code contains some div’s and a ordened list for showing a route on the map.
   But unfortunally wordpress is setting everywhere paragraph `<p>` and break `<
   br>` tags. How can prevent this, because on this way, my cool map doesnt work…
   🙁

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [19 years, 5 months ago](https://wordpress.org/support/topic/inserting-own-scriptingcode-at-a-post/#post-481250)
 * I’d suggest nixing the visual rich editor (Users > Your Profile, Personal Options)
   and see if you can insert the code using the basic editor.
 *  Thread Starter [maximus43](https://wordpress.org/support/users/maximus43/)
 * (@maximus43)
 * [19 years, 5 months ago](https://wordpress.org/support/topic/inserting-own-scriptingcode-at-a-post/#post-481291)
 * Unfortunally it doesn’t work. I tried this, with adding the html directly in 
   the database, but with showing the content, wordpress is again adding some `<
   p>` and `<br>`
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 5 months ago](https://wordpress.org/support/topic/inserting-own-scriptingcode-at-a-post/#post-481297)
 * Are you trying to paste javascript into a post? If so, try using my little plugin
   to help this along.
 * [http://ottodestruct.com/wpstuff/scriptenabler.zip](http://ottodestruct.com/wpstuff/scriptenabler.zip)
 * It should prevent WordPress from messing with your javascripts.
 *  Thread Starter [maximus43](https://wordpress.org/support/users/maximus43/)
 * (@maximus43)
 * [19 years, 5 months ago](https://wordpress.org/support/topic/inserting-own-scriptingcode-at-a-post/#post-481306)
 * Well, it is not really javascript. I use some functions, but I included them (
   directly in the source. It is not a nice solution, but it works), but the data
   hava to be specified in html (I use the gmapez tool). For example:
 * [http://bluweb.com/us/chouser/gmapez/start.html](http://bluweb.com/us/chouser/gmapez/start.html)
 * To add a marker to my google map (with gmapez), I use:
    <div class=”GMapEZ” style
   =”width: 300px; height: 300px;”> [  </div>
 * But WP is messing this by adding <P> and <BR> tags.
    Also drawing a line with
   gmapez is the
    1.  and
    2.  tag. WP is also messing this up…
 * But Otto, your script looks interesting. Is it possible to extend or change the
   script that wordpress doesn’t mess up my html??
 * for example everything between an artificial <nomess> tag:
 * <nomess>
    <div>some data that should not be messed up</div> [ EXTENT  </nomess
   >
 * I don’t know so much about the inner structure of wordpress (there are so many
   functions). Do you know how I should do that?
 *  Thread Starter [maximus43](https://wordpress.org/support/users/maximus43/)
 * (@maximus43)
 * [19 years, 5 months ago](https://wordpress.org/support/topic/inserting-own-scriptingcode-at-a-post/#post-481307)
 * hmzz. now is the link interpreted as a link: There should be the html of a link,
   like in gmapez…
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 5 months ago](https://wordpress.org/support/topic/inserting-own-scriptingcode-at-a-post/#post-481381)
 * oops – ignore this
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 5 months ago](https://wordpress.org/support/topic/inserting-own-scriptingcode-at-a-post/#post-481382)
 * > But Otto, your script looks interesting. Is it possible to extend or change
   > the script that wordpress doesn’t mess up my html??
 * Sure. Open the plugin in a text editor. There’s two functions, a Pre and a Post.
   The Pre takes out the relevant code before WordPress messes with it, and the 
   Post puts it back afterwards. If you wanted to have a “nomess” sort of tag, you
   could change the regular expressions accordingly.
 * In the Pre, you’ll find this:
    `if (preg_match_all("{\<script(.*)\<\/script\>}
   siU", $text, $temp)) {`
 * Change that to this:
    `if (preg_match_all("{\<nomess\>(.*)\<\/nomess\>}siU", 
   $text, $temp)) {`
 * Now it looks for nomess tags. You just have to fix the post portion to put the
   stuff back correctly. So in there, find this:
    `$text = str_replace('<!-- h'.
   $k.'h -->', '<script'.$v.'</script>', $text);`
 * And change it to this:
    `$text = str_replace('<!-- h'.$k.'h -->', $v, $text);`
 * That will put the text back into your post, but WITHOUT the nomess tags.
 * Should work, I think. Haven’t tried it. 🙂
 *  [vkaryl](https://wordpress.org/support/users/vkaryl/)
 * (@vkaryl)
 * [19 years, 5 months ago](https://wordpress.org/support/topic/inserting-own-scriptingcode-at-a-post/#post-481385)
 * And if you want a super simple way to insert google maps, try Windows Live Writer:
   blog page at [http://windowslivewriter.spaces.live.com/](http://windowslivewriter.spaces.live.com/)
   and download link at [http://g.msn.com/8SEENUS030000TBR/WriterMSI](http://g.msn.com/8SEENUS030000TBR/WriterMSI)

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Inserting own scriptingcode at a post’ is closed to new replies.

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 8 replies
 * 4 participants
 * Last reply from: [vkaryl](https://wordpress.org/support/users/vkaryl/)
 * Last activity: [19 years, 5 months ago](https://wordpress.org/support/topic/inserting-own-scriptingcode-at-a-post/#post-481385)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
