1. Home
  2. ReHub Theme
  3. How to …
  4. How to prevent wrong formatting in shortcode

How to prevent wrong formatting in shortcode

Sometimes, when you add shortcode in post, you will find some incorrect spaces. This is because of wrong WordPress auto formatting. For fixing this problem, just add to function.php code:

remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 99);
add_filter( 'the_content', 'shortcode_unautop', 100 );

Additionally, you may need to remove empty paragraphs via code

p:empty {display: none;}

you can place this in theme options – general options – custom css