Tinymce – How to force wp fragment to use br tag?

The wp editor was replacing the br tag with the p tag. All the solutions here didn’t work. This was causing problems with the design. So i disabled wpautop with below code….

remove_filter( 'the_content', 'wpautop' );

forgot to mention that the fraction disappears if used….

remove_filter( 'the_excerpt', 'wpautop' );

However, the problem still remains for the fraction. Adding a single br to the numerator works but two br p . become

To style the p of the fraction I am using the below filter…

add_filter( "the_excerpt", "add_class_to_excerpt" );
function add_class_to_excerpt( $excerpt ) {
return str_replace('<p', '<p class="short-desc" style="text-align: justify;"', $excerpt);
}

Currently the output is as below….

<p class="short-desc" style="text-align: justify;">text here</p>
<p class="short-desc" style="text-align: justify;">text here</p>

and i want output like below….

<p class="short-desc" style="text-align: justify;">text here<br><br/>
text here</p>

How to force wp excerpt to use br tag? Or how to prevent wp from making two br’s into p tags?

Leave a Comment