Friday, January 30, 2015

Preventing P and BR Tags in WordPress Posts


In Wordpress when you create new post or page from admin panel and when you write some content and save that post that in fronted auto add <p>..</p> and <br/> tags which display extra spaces and some times it's effect current Wordpress theme. so it must be remove from stop extra spaces in Wordpress.

This happen because of WordPress's `wpautop` function which is use changes double line-breaks in the text into HTML paragraphs.This functionality provide Wordpress for better posting with default template.This function use `wpautop( $foo, $br )` Where
$foo = The text to be formatted.
$br = Preserve line breaks. When set to true, any line breaks remaining after paragraph conversion are converted to HTML <br />. Line breaks within script and style sections are not affected.
So according to theme you want to remove extra
tag that must enter below code for content and expert as use.
remove_filter( 'the_content', 'wpautop' ); 
//Use for Post Content in post detail page
remove_filter( 'the_excerpt', 'wpautop' ); 
//Use for Post Excerpt in post archive page
Use above code in your running theme's function file.If you want to know your current running theme than login to admin panel Appearance->Themes here display all themes which theme is active that display as `Active`. Find active theme function file in Wordpress root directory `wp-content/themes/THEMENAME/function.php`.

No comments :

Post a Comment