Title: Preserving Javascript and other code blocks in posts
Last modified: August 18, 2016

---

# Preserving Javascript and other code blocks in posts

 *  [mikeindustries](https://wordpress.org/support/users/mikeindustries/)
 * (@mikeindustries)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/preserving-javascript-and-other-code-blocks-in-posts/)
 * I use inline javascript and php sometimes in posts and I’m not a big fan of how
   WordPress can’t seem to leave these blocks alone when it comes to wpautop and
   wptexturize. When code within script or php tags gets messed with by these functions,
   it often breaks. I have the text-control plug-in which allows me to turn off 
   both wpautop and wptexturize on a post-by-post basis, but really, this is not
   ideal.
 * Given that there is pretty much never *any* circumstance where text within script
   or php blocks should be touched by formatting functions, it seems to me that 
   one of two things should happen (hopefully as a standard part of WordPress) —
 * 1. wpautop and wptexturize should be improved such that they ignore at least 
   script tags and possibly php tags, and even better a configurable array of tags.
   Basically, nothing within these tags should get touched and they shouldn’t be
   wrapped in p tags either.
 * 2. There should be some sort of “no-op” markup you can add to posts which prevents
   wpautop and wptexturize from touching what’s inside. So, for instance, you could
   manually wrap a script tag in specially designated HTML comments which would 
   tell formatting functions to lay off.

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

 *  [here](https://wordpress.org/support/users/here/)
 * (@here)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/preserving-javascript-and-other-code-blocks-in-posts/#post-614871)
 * Working toward collecting and developing solutions at:
 * [http://codex.wordpress.org/How_Wordpress_Processes_Entry_Text](http://codex.wordpress.org/How_Wordpress_Processes_Entry_Text)
 *  [Adam Brown](https://wordpress.org/support/users/adamrbrown/)
 * (@adamrbrown)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/preserving-javascript-and-other-code-blocks-in-posts/#post-614872)
 * [@here](https://wordpress.org/support/users/here/):
 * You don’t need to keep digging up old threads and posting the same thing…
 * that’s typically considered spamming, even if for a good cause.
 *  [bgoulette612](https://wordpress.org/support/users/bgoulette612/)
 * (@bgoulette612)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/preserving-javascript-and-other-code-blocks-in-posts/#post-614877)
 * Just chiming in to say that I, too, am wondering how to accomplish this (or how
   I understand it): what I’m looking for is the ability to effectively keep wpautop“
   on” for the majority of a post, but selectively disable it _within_ a post; for
   example, discussing a chunk of code would use wpautop — the code itself would
   not.
 * Surely there’s a way to allow either the ` tag itself or a specially named div(
   or a set of comment-like thingies) to enable this?`
 * I've been trying, but a) I am not good with regexp, and b) I have no idea what's
   going on. :(
 *  [Adam Brown](https://wordpress.org/support/users/adamrbrown/)
 * (@adamrbrown)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/preserving-javascript-and-other-code-blocks-in-posts/#post-614878)
 * > discussing a chunk of code
 * If you only want this for discussing code, check out the various code-pasting
   plugins available.
 * There are more elaborate plugins if you want to paste code into posts, but I’ve
   written one that will do the trick. (It’s mainly for comments, but it works in
   posts too.)
 * [here](http://adambrown.info/b/widgets/category/kb-backtick-comments/)

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

The topic ‘Preserving Javascript and other code blocks in posts’ is closed to new
replies.

## Tags

 * [encoding](https://wordpress.org/support/topic-tag/encoding/)
 * [formatting](https://wordpress.org/support/topic-tag/formatting/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [wpautop](https://wordpress.org/support/topic-tag/wpautop/)
 * [wptexturize](https://wordpress.org/support/topic-tag/wptexturize/)

 * 4 replies
 * 4 participants
 * Last reply from: [Adam Brown](https://wordpress.org/support/users/adamrbrown/)
 * Last activity: [18 years, 4 months ago](https://wordpress.org/support/topic/preserving-javascript-and-other-code-blocks-in-posts/#post-614878)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
