How to remove extra <p> </p> tags in wordpress post and pages?

I have use WordPress filter but i can’t remove all extra <p></p> tags.

This <p></p> tags adding in last of page and post content.

Read More

But i want to remove all <p></p> tags in WordPress post and page view

Related posts

Leave a Reply

3 comments

  1. Please use this line of code instead of the_content(); / the_excerpt(); then it will works fine.

    for content

    <?php remove_filter( 'the_content', 'wpautop' ); the_content(); ?>
    

    for excerpt

    <?php remove_filter( 'the_excerpt', 'wpautop' ); the_content(); ?>
    

    Hope so it will help. Thanks.

  2. In PHP, wherever you have echo get_the_content($params) posted (maybe just content.php, depends on theme), do:

    echo preg_replace(array('<p>','</p>'),array('',''),get_the_content($params),1)
    

    That will replace any occurrences of <p> with the empty string ''; likewise for </p>.

    Doing this will not matter whether you author the content in HTML or Visual modes, if it’s there, it’ll remove it; if not, it won’t break it.

    If you just don’t like the style wherever you have <p></p> tags, then post p{} from style.css, and describe how you want it to look – is it the gap between paragraphs you want smaller or bigger, for example?

  3. Please try with below code:

    remove_filter( 'the_content', 'wpautop' );
    
                       OR
    
    remove_filter( 'the_excerpt', 'wpautop' );
    

    It will remove all extra <p> tags from content.

    Thanks!