Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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?

share|improve this question
    
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. –  Francesco Craparo Mar 17 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.

share|improve this answer
    
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 –  Francesco Craparo Mar 17 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 ?> –  MartinB Mar 17 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 –  Francesco Craparo Mar 17 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. –  Eric Holmes Mar 17 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? –  Francesco Craparo Mar 17 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)

share|improve this answer
    
Please accept your own answer. Thanks :-) –  Pieter Goosen yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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