
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?
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.