In Elegant Themes, like many other themes, the line break <br /> br tags were not being preserved when used within shortcodes.
For example, we have a page with tabs using shortcode [tab][/tab] and we wanted to use Shift+Enter to enter line breaks.
Although the content looked fine in the Editor, the line breaks were getting stripped and didn’t display properly in the front-end.
Elegant Themes suggested we tell our client to add <br class=”clear” /> which is not exactly… elegant for our clients.
You could also add a line break shortcode so that the client could add [br] but this is almost as annoying.
I tried the Advanced TinyMCE plugin because there is an option to “stop removing the <p> and <br /> tags when saving and show them in the HTML editor” but that didn’t work.
Finally, after lots of searching, I found this snippet in the WP Forum to add to your functions.php file.
1 2 3 4 |
function clear_br($content){ return str_replace("<br />","<br clear='none'/>", $content); } add_filter('the_content', 'clear_br'); |
Oh Happy Day!