
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, 2009You are a SAINT for posting this.
Thank you!
Steven Johnstone
November 25, 2009Thank 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, 2009awesome thank you!
Chiefs Hockey
December 17, 2009U r a freggin saint! Searched for this one liner like crazy. Thank you!
Chiefs Hockey
Phonde
December 28, 2009This is brilliant! Can’t say how many times i got my validation messed up because of that!
Thanks a lot.
David Tierney
January 6, 2010Thanks. Sometimes the little things make a big difference.
Ben Carlson
January 20, 2010How about only removing the tags surrounding images? Any idea on that?
JR Oakes
May 7, 2010I think I have a new best friend….
Shredmistress
May 12, 2010Thank 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, 2010Thanks for this post, I googled how to remove tags in wordpress and found your page :D
Bill
July 10, 2010C’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, 2010great wow super. muchas gracias from BA!
You´re a WP genious. Save my night.
:P
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.