In my point of view, WordPress is a by far one of the best CMS – Content Management System – for blogging ever created. The fact that WordPress automatically reformat the code of posts and pages written by not-so-tech-sawvy users is a brilliant feature.
However, if you like to have total control of your code, this feature can become a significant pain in you’re neck. In order to prevent WordPress from automatically adding <p> and </p> tags in your code, find the following line of code in your template file:
<?php the_content('<p>Read the rest of this page »</p>'); ?>
All you need to do is to add one line of code just before it, like this:
<?php remove_filter ('the_content', 'wpautop'); ?>
<?php the_content('<p>Read the rest of this page »</p>'); ?>
That’s it! This extra line of code will deactivate the WordPress wpautop function which is responsible for automatically changing double line-breaks into paragraphs.
5 Responses to How to Stop WordPress From Adding <p> Tags?
Great! I was looking for that everywhere! Thanks!
Thanks, saved my day!
Thanks a ton for the tip. This was driving me crazy when trying to get a jQuery slider to work. I can stop pulling out my hair now. Cheers.
This doesn’t work with me, I installed WordPress3 as a multisite, do you know if this makes a different? And the ‘s are killing me!
@Jelske: I don’t know how WordPress handles this code on a multisite installation. Have you tried to put this line of code inside the function.php file?