WORDPRESS VERSION: 3.8.1 PHP version: 5.3

I have a trouble with wordpress posts. How can I remove the auto P tags added? This is my final html code:

<div class="one_half_style_4_last">
<ul class="list-green">
<h4 class="\"pattern-bg-title-grey\"">
<span>Livelli Vip</span>
<div class="su-table table-post">
<h4 class="\"pattern-bg-title-grey\"">
<p>Invalid Displayed Gallery</p>
<h4 class="\"pattern-bg-title-grey\"">
<div class="srp-widget-container">
<p class="omc-single-tags"></p>
<br class="clear">
<div class="omc-related-posts">

There is another trouble, wordpress add slashes (magic_quotes_gpc on my server is Off):

<h4 class="\"pattern-bg-title-grey\"">

I tried to put this code in functions.php or single.php and even comment these lines in wp-includes/default-filters.php but is not working:

remove_filter( 'the_content', 'wptexturize'        );
remove_filter( 'the_content', 'convert_smilies'    );
remove_filter( 'the_content', 'convert_chars'      );
remove_filter( 'the_content', 'wpautop'            );
remove_filter( 'the_content', 'shortcode_unautop'  );
remove_filter( 'the_content', 'prepend_attachment' );

What can i do?

  • I tried to write in the post: <h4 class='pattern-bg-title-grey'><span>Articoli</span></h4> with only one quote and now the trouble is fixed but i don't know why is a problem if I use double quotes... it's a mistery. Incredible... before i hadn't this type of problem. Mar 17, 2014 at 12:15

2 Answers 2


The WordPress implementation of the TinyMCE editor automatically adds <p> tags. There's a few options for removing, as explained in a tutorial on removing <p> tags.

I would recommend the following approach, which is a slight modification from that tutorial (as it involves messing with core wp functions). Add the following code to your functions.php file which removes the auto <p>'s:

function rm_wpautop($content) {
    global $post;
    // Remove the filter
    remove_filter('the_content', 'wpautop');
    return $content;

// Hook into the Plugin API
add_filter('the_content', 'rm_wpautop', 9);

Alternatively, if you only wanted to remove the auto <p> tags on specific posts or pages or other parts of your theme template, look for the line <?php the_content(); ?> in your template files and add <?php remove_filter ('the_content', 'wpautop'); ?> before it.

  • Hi, i tried but is not working.. if i put this code into the functions.php file, the website doesn't load (blank page). :/ I even tried to put remove_filter ('the_content', 'wpautop'); before it but is not working. link Mar 17, 2014 at 12:56
  • I've tested this code and it 100% works. Make sure it is placed in your functions file before the closing php tag ?>
    – MBL
    Mar 17, 2014 at 13:00
  • yes before the tag ?> but is not working and i don't know why... the other problem is the slashes added before the double quotes. I'm becoming crazy today Mar 17, 2014 at 13:11
  • If your page is blank - that generally means that you have a PHP error happening, and display_errors = Off in your php.ini file. It's probably a simple syntax issue. Mar 17, 2014 at 13:45
  • no blank page now but is not working as well. There is another problem -> <h4 class="\"pattern-bg-title-grey\""> Wordpress added the slashes, why? Mar 17, 2014 at 13:54

Ok.... I fixed the second trouble! The problem was a option in this plugin: SEO Smart Links

I disabled this field: Prevent linking in heading tags (h1,h2,h3,h4,h5,h6)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.