Digital Media Marketing Agency – Red Rokk | Removing P Tags in WordPress » Digital Media Marketing Agency - Red Rokk

Removing P Tags in WordPress

  |   WordPress   |   5 Comments

By default, WordPress will automatically inserts p tags throughout your content. This can seriously screw up the layout/design and cause validation issues. There are a couple of ways to fix this, depending on your technical expertise and where you would like to prevent this from taking place.

Here are three options:

  1. Throughout entire site
  2. On specific template pages
  3. With specific page items

Throughout your entire site:

Here’s a quick and easy fix to stop WordPress from placing p tags anywhere within your site. You will need to open your /wp-includes/default-filters.php file and comment out the following line:
addfilter('the_content', 'wpautop');

To comment out a line in a PHP file, insert two forward slashes //  in front of the line. When you’re done, this is how it should look:
//addfilter('the_content', 'wpautop');

On specific template pages:

This method allows you to stop WordPress from using theses tags on specific template pages (i.e. page.php, home.php, index.php, or any custom template page). You’ll need to open the page in an editor such as the built in WordPress editor or Dreamweaver.

<?php the_content(); ?>

and place this directly above:
<?php remove_filter (’the_content’, ‘wpautop’); ?>

it should look like this:
<?php remove_filter (‘the_content’, ‘wpautop’); ?>
<?php the_content(); ?>

With specific page items (pics, field labels, content):
This one is also fairly easy. While creating a page or post within WordPress, you have the ability to type in either the “Visual” or “HTML” tab. Feel free to create the post in visual, but when you’re done, you’ll need to switch over to HTML. Locate the item you’d like to remove the <p> tag on, and place <div> tags around it instead. You’ll need to make sure that you place div tags around each item for this to work. Below is an example:

<div>Example Item</div>

Need more digital marketing help? Contact us! We specialize in maximizing conversions and increasing our client’s ecommerce sales.

See what we can do for you: email or call (360) 747-7401.'

AUTHOR - byrd


    Jake | Sep 2, 2010 at 3:48 am

    Hey Johnathon,

    Great post and it fixed my problem! BUT, I am in wordpress 3.0.1, and every time I tab between visual and HTML editor it *removes my p tags. And that messes up my layout even more than when it used to insert random p tags. So is there a way to take *both automations off? This seems like a stupid problem to have, I wish that it wouldn't mess with my HTML at all. Thanks!


    Sofia | Sep 2, 2010 at 4:22 pm

    I've been having a problem similar to Jake's. When I switch from HTML to Visual and edit something on Visual it screws with the HTML code, which drives me crazy. WordPress also switches my < to &; or something like that. Why does this happen? Is there a fix?



    From PDX with Love


      Website Help | Feb 22, 2012 at 12:23 am

      Same problem as sofia, but fixed now. Thanks for the help guys.


    Tyler Byrd | Sep 4, 2010 at 6:03 am

    Jake this is most likely do to your WYSIWYG editor attempting to clean your code. First make sure you are not forgetting to close your tags or missing an < or > sign. This is most frequently the cause for getting your tags removed.

    By default WordPress comes installed with TinyMCE. If you are still running into problems take a look at downloading a different WYSIWYG editor from WordPress's widget database. You should be able to find several that will work for you.

    Hope this helps.


    mark | Jan 8, 2013 at 5:00 am

    This post saved me from so much grief! This is, single-handedly, the most helpful post in the history of the internet.