Recruiting the Next Gen

Removing P Tags in WordPress

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

Here are the three options:

  1. Through out entire site
  2. On specific Template pages
  3. With specific page items

Through out your entire site:

Here is 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 your done, this is how it should look:
//addfilter('the_content', 'wpautop');

On specific template pages:

This method with allow 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 will 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 are done you will need to switch over to HTML. Locate the item you would like to remove the <p> tag on, and place <div> tags around it instead. You will need to make sure that you place div tags around each item for this to work. Below is an example:

<div>Example Item</div>

Hope this helps.  If you have a question, email it over to use via our contact form, we would be happy to help.

Tyler Byrd

As the President and managing partner of Red Rokk, Tyler is part entrepreneur, part strategic planner and complete visionary for the agency team. After co-founding Monsterpod Technologies in 2005 and breaking the $1M in revenue mark in its first year, Tyler went on to start Red Rokk in 2011 and has since been named business person of the year by The Bellingham Business Journal and won the "most valuable player" award by the Bellingham/Whatcom Chamber of Commerce in 2013.
Removing P Tags in WordPress
  1. Jake


    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!

  2. 9

    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

  3. Tyler Byrd


    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.

  4. mark


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

Leave a Comment
Username *
Email *
Website *

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Leave your email and we'll let you know when there's something exciting happening.

Or Follow Us

Close this popup