Home   |   TWP Auctions   |   Contact
The Website Professionals
Real world webmaster resources.
TWP Auctions - the free eBay script RSS feed Twitter

Stop WordPress from automatically inserting paragraph tags

Wordpress paragraph tags

By default, WordPress automatically inserts paragraph tags all over the place when displaying ‘the_content’ – this often gets in the way when you’re trying to space out your text, and also creates validation issues (inserting implicit <p>). If you want to strip the automatically inserted paragraph tags from your content, simply insert this line in your template file above ‘the_content’ tag:
<?php remove_filter (‘the_content’, ‘wpautop’); ?>

Comments

Jason

June 9, 2009

You are a SAINT for posting this.

Thank you!

Steven Johnstone

November 25, 2009

Thank you so much! I spent over five hours searching for answers as to why my perfect XHTML code was failing to validate once included in my WordPress template ‘the_content’ area.

Your one line of code has saved me!

Thanks again
Steven J

Bryan

December 5, 2009

awesome thank you!

Chiefs Hockey

December 17, 2009

U r a freggin saint! Searched for this one liner like crazy. Thank you!

Chiefs Hockey

Phonde

December 28, 2009

This is brilliant! Can’t say how many times i got my validation messed up because of that!
Thanks a lot.

David Tierney

January 6, 2010

Thanks. Sometimes the little things make a big difference.

Ben Carlson

January 20, 2010

How about only removing the tags surrounding images? Any idea on that?

JR Oakes

May 7, 2010

I think I have a new best friend….

Shredmistress

May 12, 2010

Thank you so much for this advice. I was trying to validate my ‘pages’ and could not figure out why there were random opening tags. I added this code to my page.php template.

pete

May 12, 2010

Thanks for this post, I googled how to remove tags in wordpress and found your page :D

Bill

July 10, 2010

C’mon… a saint!?

No, this came at a great find in the Google Search…
a demi-God more like :P

nice work, and thanks for the insights, truly helpful, saved one of our latest releases coming out shortly.

Juan Pablo

July 12, 2010

great wow super. muchas gracias from BA!
You´re a WP genious. Save my night.
:P

Rory

September 17, 2010

Thanks took me to seconds to find a solution for a 2 hr problem

Tison

September 29, 2010

THANK YOU SO MUCH!! This is the only solution I’ve seen that conditionally allows you to deal with the auto “p” issue. The only other way I’ve seen is to shut it off entirely in wordpress settings, which won’t do as you still want to allow your users to insert paragraphs.

This allows you to address the issue on a per-page/post basis in your theme.

Thanks so much

Bruce Knight

October 18, 2010

You are truly amazing! Thank you so much for this post I was looking all over the internet to find the solution to solve this problem but you have helped me in seconds… Thank you so much!

Pappy Gatmuss

November 3, 2010

THANK YOU! If there is one thing that drives me about WordPress it was ghost p tags.

This is the best thing since slide bread and two-ply toilet paper.

Gerardo Ritchey

December 3, 2010

You sir, are my hero!

You just made my life sooooo much simpler.

Cathy

February 8, 2011

Thank you so much! WordPress inserting phantom paragraphs was doing my head in until I found your page.

Benjamin

April 30, 2011

Thanks for this post. Two years old and it’s still helping!

In case someone else has this problem: I copied directly from the snippet and it didn’t work, because of the quotes. Depending on your editor, you might have to retype the quotes or just type the whole line instead of being lazy (like me).

Jack

May 17, 2011

Benjamin, thank you for your comment. It wasn’t working for me until I deleted and retyped the single quotes in my editor. Now it works.

Seth

June 1, 2011

OMG thank you so much! I was pulling my hair out. And yes, Benjamin is correct. If you cut and paste this code you get “smart” single quotes which will break the code. Replace them with regular single quotes.

Chris

June 24, 2011

Thank you very much … like many others, this has been causing me all kinds of problems. Cheers, Chris

sayito

July 7, 2011

Thank you!! I have been trying to do this for ages.

Ian

December 12, 2011

My problem is that it strips p tags when I’m trying to put them in manually. I’ll try this and maybe since it won’t be putting them in, it will not take mine out?

Thanks

Leave a comment

This is a dofollow website. If you leave a comment, then we'll give you a backlink.
Please be aware that this website is strictly moderated. If you post spam, you'll get a slap.










Featured webmaster products for February 2012:
Use a different photo for every card

Copyright © 2012 The Website Professionals - All rights reserved
Links | Privacy policy