Pages

Monday, April 28, 2014

Remove Extra "P" tags from content area in wordpress- [resolved]

If you want to remove extra "<p>" tags from content than please write below code in your functions.php

Method 1:

function wp_remove_extra_p_tags($content) {
    $array = array (
        '<p>[' => '[',
        ']</p>' => ']',
    );
    $content = strtr($content, $array);
return $content;
}
add_filter('the_content', 'wp_remove_extra_p_tags', 10);


Method 2:

function wp_remove_extra_p_tags($content) {
    $content = str_replace(array("<p></p>","<p> </p>"),"",$content);
    return $content;
}
add_filter('the_content', 'wp_remove_extra_p_tags');

No comments: