Been swearing at WordPress this afternoon…
I’ve been trying to transfer an html form, which I had working perfectly on a static html page, onto a WordPress page. WordPress insisted on adding multiple <br/> tags where I didn’t want them. Mutter.
Eventually, after much searching, I identified a parameter within wp-includes/formatting.php, which allows you to disable this irritating feature. If you open formatting.php and find the function wpautop you’ll see this:
function wpautop($pee, $br = 1)
Change this to:
function wpautop($pee, $br = 0)
Save the file and publish it back to your server and that’s it. Works fine in WP2.8.
Note: WP 2.8.3 overwrites formatting.php so this change needs redoing.
Update 24 October 2010
Fed up with repeatedly doing this I’ve developed a WordPress plugin to address the issue. Give it a try and let me know if it works for you.
Yes, but that remove all the formatting entirely. This just stops the unnecessary line breaks.
You can just add 2 lines at the end of the functions.php file.
http://iiiji.com/remove-automatic-and-tags-in-wordpress-2/
Thanks
I can’t recreate this – if I paste a table into WordPress it does not wrap any tags around it.
How do you stop WordPress adding tags before tables???
Please can someone help me before I don’t have a head left. lol
This problem were making me mad, i used br {display:none;} with no success previously but the solution you’ve revealed here is the best answer. thanks a zillion
Thanks so much be searching for a solution to this problem for a looong time.
Thanks a lot!
You are Great!
In WP 3.8:
function wpautop($pee, $br = false) {
$pre_tags = array();
yeah, it works! thanks a lot
Thanks mate!
Yes, the p tags will still be there because the code described just prevents the addition of br tags.
See my response 29 above to disable all formatting.
Hi Guys,
Am getting added and in my post where am using [APCAL] (appointment calendar plugin short-code).
My theme details:
Theme Name: Balance
Author: Ignitethemes & Weblusive
Version: 1.2
I have tried above solution and all tags has been removed but tags are still there.
Please help me to solve out this problem.
Correcting my above post: br tags gone but p tags are still in post content.
If you want to stop the formatting altogether then you can use the following:
Paste this into your theme’s functions.php.
How to disable auto p tag.
Thank u very much. You are such a nice guy
Just wanted to throw out a quick Thanks. Just what I needed. -P
Superb solution,thanks a lot!
Exactly what I was looking for, thank youvery much!
Cheer!
Um…it’s in, well, wp-includes….but you might be better using the plugin anyway.
Where is the wp-includes/formatting.php file?
You have
return nl2br($post->post_content);
in your function.
still. no luck.
can u please tell me. Why its adding BR in DIVS and just before h tags. The problem is since i cutted thr tab content from HTML to WordPress as post/page.
I’m calling the page using call getPageContent Function.
can u tell why. This is the function
http://www.tanzilo.com/2008/11/01/wordpress-get-page-content-by-page-id-static-pages-to-dynamic/
I am in your debt, thank you!
Thanks Simon, this was driving me batty!
Thanks so much! been looking for that =) WordPress does a lot of strange things for which aparently there is no explanation. For example I can do things in the header and they work but if I do them in a static page of theirs it doesn’t. s have a weird extra 6px bottom margin in spite of there not being any in the CSS.
What I mean to say is, thank you! =)
THANKS!!!!
…which is what I’ve said, and why I wrote the plugin…
Definitely NOT the proper way to do this guys. If you ever update WordPress, you’ll need to edit this each time. Best option is to wrap the fix in a custom function.
You total and utter legend – its been driving me nuts
tx!It can solve the problem
Thanks! This was driving me crazy!!! And this fixed it 🙂
Thanks a million, I was pulling my hair out!
Thanks!!! I was stumped with this one when creating some shortcodes.
Great post – thanks so much.
What an annoying little feature that is – auto adding line breaks behind your back!
You are a life-saver! I am forever indebted to you!
Awesome – this helped me out heaps. Thank you.
Thank you so much!
Awesome. I too was doing some headbutting. $#%!!!
Thanks a lot for posting this solution!
I can now stop headbutting the desk – until the next update.
Great solution! It works perfectly! Thanks for sharing!
cheers, mate!