Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove extra <p> in WordPress?

I'm new to wordpress and currently developing a theme on it. I have noticed that Wordpress adds <p> tags all over the page. Do you know any plugin or a workaround to avoid this?

like image 641
Ozzy Avatar asked Dec 06 '22 02:12

Ozzy


2 Answers

Add this to your functions.php, this should give the result you're looking for:

remove_filter('the_content', 'wpautop');
like image 58
gasoved Avatar answered Dec 07 '22 15:12

gasoved


Try this, assuming you have the html code in variable $html_code

$html_code = preg_replace('/<\/?p>/','', $html_code);
like image 31
cypher Avatar answered Dec 07 '22 16:12

cypher