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 disable the automatic formatting that WordPress applies to post content. This plugin adds a set of shortcodes that you can use to “protect” specific parts of your post and prevent WP from messing with them.
Download & Installation
Requirements :
- WordPress 2.8 or later
- If you use the free version, I strongly recommend disabling the visual editor. It (the editor) can mess up your code even if you use this plugin.
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 “Edit Post” screen:
If you want to prevent a specific part of your post or page from being processed and “texturized” by WordPress, wrap it in ... or <!–raw–>…<!–/raw–> tags. The two versions work exactly the same, with one exception – the <!–raw–>’s won’t be visible to your visitors even if you deactivate the plugin.
Example :
<!--raw-->
This
is
a ‘test’!
<!–/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.
Related posts :
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 😀
The example worked fine. Then I tried on frame redirect code and no redirect. Does WP filter anyway?
Could you post the code you’re trying to use? I’m not quite clear on what “frame redirect code” means.
[…] automatic formatting functions from wordpress. No more useless P-tags in the middle of your post andVisit plugin site »9 – Shadowbox JSA javascript media viewer similar to Lightbox and Thickbox. Supports all types […]
[…] Raw HTML capability 修正wordpress的自動修正語法不當的狀況(例如美式的引號會被轉成其他符號)。 […]
Great plugin. One question though. How would I get the code to process other shortcodes inside the [RAW] tags? I use a lot of short codes, and the plugin just echoes the short code tags instead of processing them.
In short, you can’t. The whole point of this plugin is not to let WP modify anything within the [RAW] tags. So not executing shortcodes is by design.
[…] nazywa się Raw HTML http://w-shadow.com/blog/2007/12/13/raw-html-in-wordpress/ i doskonale się to tego nadał. Po prostu we wpisie umieszczamy tagi <!–start_raw–> i […]
After I posted that, I realized what a stupid question it was. I don’t need to wrap my code in RAW tags. I just disable autop with the checkboxes and all my shortcodes work great.
@Ryan – Good on yuh for saying so. In my experience it’s just that sort of “mistake” that gets me chasing my tail … horribly frustrating to over-look the obvious.
cheers!
Hi,
I would just like to say “Thank-you” for making such a time saving plugin! I spent all of today trying to add an html page to WordPress. It wasn’t as easy as just copying from the to . Your plugin was the light at the end of a dark tunnel! This dark tunnel lasted the whole day!
Thank-you, Thank-you!!!
It seems this does not prevent all WOrdpress filtering. I am trying to use some nonstandard HTML tags within post and even with this plugin, Worpdrepss stil manages to completely remove those tags.
It does not happen if I enter tags in HTML mode and save post. It happens when I enter tags in HTML mode and then just switch to WSYIWG mode. Tags are deleted at once.
I need those tags as they are used for additional formatting on post display which I do from my plugin.
Is there way to prevent this kind of filtering HTML?
This plugin does not affect the visual editor in any way. It’s purpose is to deal with the filters that WordPress applies when displaying the post on your blog.
Solution : Don’t use the visual editor when you need to use non-standard tags.
I also noticed that plugin does not work on posts displayed on first page in blog, and RSS feeds.
Hmm, I’ll put fixing that on my to-do list.
[…] 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. […]
Simply, i love you
I would LOVE to see the default settings on for this plugin… Any chance to have it?
I’ll add it to my to-do list, but it’s unlikely to get implemented any time soon.
Thanks! Although if someone installs this plugin, it’s likely he’s using it so changing the default box to checked would save time for most of us. It’s just 4 extra attributes in HTML, please consider an earlier upgrade 😉