Have you heard the buzz about Sustainable Brands?

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.

Locate:
<?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

Tyler Byrd is a global marketing and social media expert who has been connecting people and products through technology for more than a decade. As co-founder of Red Rokk Interactive, a Bellingham-based advertising agency, he has worked with such well-known customers as Papa Murphy's, Body Glove and H&M. Voted the Bellingham Business Journal's 2013 Business Person of the Year, he has a passion for community involvement, innovation and entrepreneurship. Website: http://www.linkedin.com/profile/view?id=22009229
Leave a Comment