How to Remove the Unwanted p Tag that Wordpress Adds?

September 7th, 2009 Fadi El-Eter Posted in Programming No Comments »

Wordpress has this annoying habit of adding <p> tags to your post. Most of the times you don’t care, but sometimes it breaks your HTML and makes it non-compliant with W3C. Some have written a component just to handle this, the solution is very simple:

If you want to remove the <p> tag that is added automatically, then all you need to do is to edit the file default-filters.php in the wp-includes directory. Search for this line:

add_filter(’the_content’, ‘wpautop’);

and comment it out by adding // in the start of the line (sorry I have to explain this for non-programmers), so ultimately the line will be:

//add_filter(’the_content’, ‘wpautop’);

Save the file and upload it. There you go, no more of these annoying <p> tags!

This method has one disadvantage, is that when you upgrade Wordpress you have to redo the above, still, it can take you only 1 minute.

AddThis Social Bookmark Button