logo

Δ All posts

Problem with WordPress messing up HTML with P and BR tags.

18 August 2007

Maybe you don't want to disable wpautop but you are sick of WordPress adding

and
tags to your included html.

A solution is to open up wp-includes/formatting-functions.php and modify the wpautop function. In this version, you can make wpautop respect any tags you want. Just add them!

Usage

Simply add your tag name inside the variable below, using the same tag-pip-tag format:
   //WP Version 2.0.4
   function wpautop($pee, $br = 1) {
           $allowedTags = 'table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre| select|fieldset|legend|form|blockquote|address|math|p|h[1-6]';
           $allowedCloseTags = 'option|select|p|li|div|dl|dd|dt|th|pre|td|ul|ol';

//WP Version 2.2.3 function wpautop($pee, $br = 1) { $pee = $pee . "n"; // just to make things a little easier, pad the end $pee = preg_replace('|
s*
|', "nn", $pee); // Space things out a little $allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr)';

ATTENTION

If you mess up WordPress and can't get anything to work, you should have made a backup! Sorry!

Relevant links

WordPress Forums: How do I remove <p> from the_content ? WordPress Forums: Hey Wordpress STOP Screwing up my HTML in my posts!

Comments

1 Yeago says...

PS. If you are having this problem but are using a version other than 2.0.3, and you're not PHP-saavy, and want me to re-write your function... please go to your formatting.php and paste me your wpautop function.

Posted at 4:35 a.m. on August 21, 2007

2 noname says...

The allowed functions are now in this file as of WP-2.2.2

wp-includes/kses.php

Posted at 2:08 p.m. on August 29, 2007

3 axa says...

USELESS,,,

Posted at 12:51 p.m. on September 17, 2007

4 Yeago says...

...totally useless.

(Unless of course you're posting HTML, in which case useFUL).

Posted at 1:46 p.m. on September 17, 2007

5 wassup says...

hello. i need some online support pls if u can, just 5 minutes. thx.

ps: u have my e-mail adress in the form (if u have yahoo mess would better)

Posted at 3:54 a.m. on January 2, 2008

just realized how annoying linking twitter to facebook would make him on facebook. UNDO.

...twittered about 4 days ago

Projects