Stop WordPress from adding p tags and removing line break

The hook to keep line break and  convert newline characters to BR tags “<br/>” also keep the redundant BR tags like “<br/> <br/>”  in editor of wordpress, just add the below hook in functions.php :

<?php

function tinymce_config( $init ) {
// Don’t remove line breaks
$init[‘remove_linebreaks’] = false;
// Convert newline characters to BR tags
$init[‘convert_newlines_to_brs’] = true;
// Do not remove redundant BR tags
$init[‘remove_redundant_brs’] = false;
// Pass $init back to WordPress
return $init;
}
add_filter(‘tiny_mce_before_init’, ‘tinymce_config’);

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s