How to Stop WordPress From Adding <p> Tags?

March 22nd 2010 | Archived under Blogging, Tutorial | 5 Comments | RSS

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.

Sponsors

Resources