Raw HTML Plugin for WordPress
Introduction
Recently I needed to put some style definitions and a JavaScript function in a post on another blog that I have. I wasted several hours trying to do this, because WordPress insisted on putting backslashes in front of my apostrophes, inserting superfluous <p> or <br /> tags in place of newlines, and generally breaking my HTML in various horrible ways.
In the end I decided to just go and write a plugin that would let me put any code or script (e.g. JavaScript) in my posts and display it to the visitor unmodified.
Download & Installation
raw-html.zip (3 KB)
Requirements :
- WordPress 2.3.1 – 2.7
- Disable visual editor for better results – some characters (e.g. the ampersand) may still be encoded if it’s enabled.
Installation is straightforward – download the zip file, unzip, upload the raw-html folder to /wp-content/plugins and activate it in the Plugins tab.
Usage
There are two ways to use the plugin. First, to turn off “smart quotes” and other built-in filters for an entire post, use the checkboxes that Raw HTML adds to the “Write” screen (requires WP 2.5+) :

If you want to prevent a specific part of your post or page from being processed and “texturized” by WordPress, wrap it in <!–start_raw–>…<!–end_raw–> or [RAW]…[/RAW] tags. The two versions work exactly the same, but the latter may be handy if you’re using the visual editor (not recommended).
Example :
<!--start_raw-->
This
is
a 'test'!
<!--end_raw-->
Result :
This
is
a 'test'!
If you view the source code of this page, you will see that the newlines are still there, and the apostrophes haven’t been converted/escaped.
Other Notes
This plugin is provided AS IS, with no guarantee that it will work on your site. If it works for you, consider yourself lucky
If deactivating Raw HTML doesn’t help then the problem probably wasn’t caused by this plugin in the first place. The plugin doesn’t make any persistent changes to a blog – deactivate it and it stops. The plugin-specific tags (e.g. <–start_raw–>) would remain in the post (if you inserted them) but they wouldn’t do anything.
Få din egna HTML-kod att fungera i WordPress-inlägg…
WordPress är inte speciellt bra på att acceptera HTML-kod i inlägg. Koden förvrängs som regel med radbrytningar, taggar och en del försvinner helt enkelt. Om du någon gång provat att klistra in ett par rader Javascript så vet du vad jag menar…….
!RAWBLOCK0!
There is a problem with the latest WP ??
I get this with just
This
is
a ‘test’!
or even just puting
And nothing else.
Are there compatibility issues with other plugins??
I received a similar report a few weeks ago and it turned out to be a compatibility issue with the “Share On Facebook” plugin. It’s probably something similar in your case.
[...] the html that you provide. To supress this function, the Raw HTML plugin was installed (visit the documentation website for more [...]
[...] Raw HTML Plugin for WordPress Raw HTML Plugin for WordPress doesn’t let WordPress to put backslashes in front of apostrophes, insert superfluous tags in place of newlines, and break HTML in various ways. This plugin lets you put any code or script (e.g. JavaScript) in your posts and display it to the visitor unmodified. [...]
Can this plug-in be used at the latest version of Wordpress 2.8.4?
Yes. As far as I know, it should work fine.
Hello, long time I don’t come to your site!
And I came again to ask the same question, what changed on v1.2.4?
A changelog was added
Check the readme.txt, or here. No changes otherwise.
THANK YOU! THANK YOU! THANK YOU!
God, it was killing me that when wordpress was stripping/changing my div tags and such.
[...] [...]
Hi, when I installed the plugin on one blog it works great, however when installed on another blog I can see my code in the page source!
Do you know what the problem could be?
What do you mean by “see [your] code in the page source”? What code would that be/why is that bad?
[...] Raw HTML Tango Smileys Extended WordPress.com Stats WP to Twitter [...]
for wordpress MU 2.8.4a the only way I could get the autop to not add the p tags to my content was to comment out the call to wpautop in wp_richedit_pre method in wp-includes/formatting.php.
function wp_richedit_pre($text) {
// Filtering a blank results in an annoying \n
if ( empty($text) ) return apply_filters(‘richedit_pre’, ”);
$output = convert_chars($text);
// $output = wpautop($output);
$output = htmlspecialchars($output, ENT_NOQUOTES);
return apply_filters(‘richedit_pre’, $output);
}
[...] The boys of lightly seasoned were looking for a way to disseminate their events, pictures and videos. The more I work with CMS built sites (WordPress in this case), the more I buy in to the idea of owner of the site maintaining the content without knowing or writing a lick of code. The events calendar is fed from a user owned Google Calendar making use of the wpng-calendar plugin. The pictures live in a user owned Picasa account and makes it way to the page courtesy of the shashin plugin. To bring the JavaScript to the page, I make use of the Raw HTML plugin. [...]
Amazing plugin! ++++
thank you for a good tool.
[...] post by White Shadow and syndicated here by [...]
Well done! Big thanks for you from Russia! This plugin has really help for me.
Can you make this compatible with the Intypo plugin? Thanks!
Done. The update will be up on wordpress.org in a few minutes.
RAW-HTML I had view a lot of plug-ins to find this one. Hell yea…this was exactly what I was looking for. The reason I needed this plug-in was all the Google Docs plug-ins that I had used…failed! This plug-in is in fact the most successful plug-in to use for embedding Google Docs.
It worked!!
I embedded a google form on my wp site!!
Yay!
Thank you!
Wow that great. Thanks for that pal..
It works great on Posts how can I get this to work on Pages?
Normally you don’t need to do anything special to make it work on pages. Can you think of anything unusual about your pages that might be causing the problem? Non-default templates? Some kind of page plugin (whatever that might be)?
For whatever reason it Pages mess up my HTML as bad as Post… Huge spaces all kinds of line breaks….
For now I will forward my pages to a post and use this great tool.
Unless someone has experienced this crazy problem.
Thanks WS
I’m sorry, but I can’t see where everyone is having these problems, even in the latest edition of WP. For most of these issues regarding html, a simple html editor can be used first to test the html. When applying the plug-in, I had never experienced any difficulties where the plug-in didn’t work. Is there anything that anyone would like me to try in attempt to localize any further issues?
hello!
how about, instead of having 4 custom fields for each post, having only 1 and storing the 4 values in a string?
It would avoid cluttering the database, since each of them is a simple boolean value.
For backward compatibility, everytime a post is read you verify both cases, but for writing you always try to remove old custom fields and update it with new one.
Wordpress should natively have options to remove these filters from posts, tnx for the plugin