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+) :

Raw HTML meta box screenshot

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 ;)

Share :
  • Reddit
  • del.icio.us
  • Digg
  • StumbleUpon
  • DZone
  • Ping.fm
  • Sphinn
Related posts :

143 Responses to “Raw HTML Plugin for WordPress”

Pages: « 1 2 3 4 [5] Show All

  1. 114
    Dave says:

    Brilliant!

  2. [...] Leidsin ka võimaluse kuidas WordPressi all sisestada javascripti ja teisi HTML tag’e. Selleks on vaja plugin’at nimega RawHTML [...]

  3. [...] 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. [...]

  4. 117
    Hikari says:

    What changed on version 1.2.3?

  5. 118
    Hikari says:

    BTW, what plugin do you use to have this “Manage your subscriptions” feature? :D

  6. 119
    White Shadow says:

    I partially replaced regular expressions with simple string manipulation because regexps were hitting some ridiculously low input limit when processing long posts. You won’t notice any difference if you didn’t have this problem.

    I use the Subscribe to Comments plugin for that feature.

  7. 120
    Tobias says:

    I would love to see an option that forces RAW on everypost. Or every new post I should say.

    Thanks!

  8. 121
    White Shadow says:

    Mmm, a settings page with a single option… pretty unlikely.

  9. [...] Raw HTML capability — δεν γίνεται προγραμματιστικό blog χωρίς αυτό [...]

  10. 123
    Dave says:

    Hi Janis,

    I think Raw HTML is stripping paragraph tags even on posts/pages where I haven’t told it to. For instance, I’ll add carriage returns in the visual editor, or I’ll add tags by hand using the HTML editor, and they’re always stripped out. I’ve tried deactivating the plugin, but that doesn’t help. This wasn’t happening before I installed Raw HTML.

    This is on a new blog running 2.7.1 (and Raw HTML 1.2.3)

    Have you seen this before?

  11. 124
    White Shadow says:

    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.

  12. 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…….

  13. 126
    Todd says:

    !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??

  14. 127
    White Shadow says:

    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.

  15. [...] the html that you provide. To supress this function, the Raw HTML plugin was installed (visit the documentation website for more [...]

  16. [...] 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. [...]

  17. 130
    Digital Nomad says:

    Can this plug-in be used at the latest version of Wordpress 2.8.4?

  18. 131
    White Shadow says:

    Yes. As far as I know, it should work fine.

  19. 132
    Hikari says:

    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? :P

  20. 133
    White Shadow says:

    A changelog was added :P Check the readme.txt, or here. No changes otherwise.

  21. 134
    Ant says:

    THANK YOU! THANK YOU! THANK YOU!

    God, it was killing me that when wordpress was stripping/changing my div tags and such.

  22. 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?

  23. 137
    White Shadow says:

    What do you mean by “see [your] code in the page source”? What code would that be/why is that bad?

  24. [...] Raw HTML Tango Smileys Extended WordPress.com Stats WP to Twitter [...]

  25. 139
    Jeff says:

    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);
    }

  26. [...] 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. [...]

  27. 141
    Claire Wakters says:

    Amazing plugin! ++++
    thank you for a good tool.

  28. 143
    Anton Kolin says:

    Well done! Big thanks for you from Russia! This plugin has really help for me.

Pages: « 1 2 3 4 [5] Show All

Leave a Reply