1

When writting a description for a Woocoomerce Product and inserting a line break with br or p Tag, WordPress automatically removes it. This is really annoying because on some points, i want to have a little line break.

I often found the solution to install TinyMCE. After that now WordPress doesnt removes the p Tag anymore but inserts a &nbsp inside of it and so the line break is way to big.

So i want a line break like a p Tag, because npsb produces way too much space between two sentence.

I also tried following solutions:

  1. add some attributes to the p Tag like <p data-x> </p>

  2. Wrap the p Tag with comments like

<!-- wp:html --> <p class="beer"></p> <!-- /wp:html -->
  1. Added some hooks in the functions.php like
add_shortcode("br", "br_tag"); function br_tag(){ return("<br/>"); }

or

remove_filter('the_content', 'wpautop'); remove_filter('the_excerpt', 'wpautop');

and

remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); function wpse_wpautop_nobr( $content ) { return wpautop( $content, false ); } add_filter( 'the_content', 'wpse_wpautop_nobr' ); add_filter( 'the_excerpt', 'wpse_wpautop_nobr' );
  1. I tried following solution but it doesnt work Wordpress automatically adding "&nbsp;"?

The "best" solution i found was to NOT using the visual AND the text editor, but for me thats such a temporary one.

Specs:

WordPress 5.6

Advanced Editor Tools (previously TinyMCE Advanced): 5.6

WooCommerce: 4.6.1 (but in my opinion, its not a WooCommerce problem)

Does anyone know a better solution or a reference for that problem?

2 Answers 2

0

Solved Problem with activated the prevent "remove <br> and <p> tag" option and inserted a <p><!-- Break --></p> when using a <p> tag. The comment prevent that the tag would remove or filled with &npsb

0

WordPress best practice is use as few plugin as possible , below method allow you inject line break without any 3rd party plugin

  1. Go to Edit page\post screen , browser address bar shall navigate to something like this , https://www.yourdomain.com/wp-admin/post.php?post=5&action=edit
  2. Click text editor

3) Avoid writing <p> , <br> or <span> , use <br class=""> in you want inject new line

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.