WordPress.org

Support

Support » How-To and Troubleshooting » I want to write pure HTML in my posts!

I want to write pure HTML in my posts!

  • I’m getting pretty fed up with WP2.2 and is seriously considering going 2.0 instead, even though I need the CMS capabilities of 2.2.

    Here’s the thing: I want to write pure HTML in my posts and pages. That means no auto-linebreak-to-br-conversion, no p-tags and no nothing. To avoid the auto-br-thing I’ve modified formatting.php so that $br = 0 by default. This works like a charm for posts and pages. Only problem is, I want auto-br to be enabled in the comments and with my little hack that doesn’t happen.

    Here’s the code I’m talking about (from wpautop()):

    // Begin pseudocode for wanted functionality:
    if(this_is_a_comment) {
    	$br = 1;
    }
    else {
    // do nothing since $br = 0 by default)
    }
    // end pseudocode
    if ($br) {
    	$pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "<WPPreserveNewline />", "\")', $pee);
    	$pee = preg_replace('|(?<!)\s*\n|', "\n", $pee); // optionally make line breaks
    	$pee = str_replace('<WPPreserveNewline />', "\n", $pee);
    }

    Anyone know how I can make this pseudocode into proper code? Or any other hacks for making this god-awful formatting on posts and pages go away?

    EDIT: And yes, I know there’s a million threads on this and related subjects, and I’ve been through them all without finding a solution.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Would using the Text Control plugin do what you want? You can remove all text formatting and filtering using it. (It’s typically used to add javascript directly inside a post or page)

    Moderator Samuel Wood (Otto)

    @otto42

    WordPress.org Tech Dude

    Why not just disable wpautop entirely if you don’t want it modifying your posts?

    Plugin to do that here: http://ottodestruct.com/wpstuff/disableautop.zip

    harknell: Thanks for the tip. It worked like a charm.
    Otto: Does it only disable it for posts and pages, or comments as well? Coz I need it enabled in the comments.

    Moderator Samuel Wood (Otto)

    @otto42

    WordPress.org Tech Dude

    It only disables it for the_content, which is posts and pages, not comments.

    Hi otto,

    Below are the issues regarding text formatting from my client. He is using wordpress-mu 1.2.1

    1) He wants to post the content (raw html with javascript), through code tab editor (when the visual editor is enabled).

    2) Currently when posting content, wordpress actually formats the content resulting in incorrect html format.
    Such as javascript tag gets removed, adds
    after each carriage return, changes — to –

    He wants a plugin that bypasses text formatting, while posts are made using code tab editor (when Use the visual editor when writing option is selected)

    I tried with wpautop plugin. Once enabled it actually does the required function, but the earlier posts gets messed(font chagnes, line spacing goes off,..)

    Please suggest on this or some other plugin….

    Inputs are welcome…

    Thanks
    Naveen

    does Text Control plugin works well in wordpress-mu 1.2.1 version?

    Otto42! Great plugin. It’s exactly what I needed!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘I want to write pure HTML in my posts!’ is closed to new replies.