Remove the br and p tags automatically added in the WordPress short code

WordPress comment 1.7K Reading mode

The default WordPress will automatically add br or p tags to the shortcode, which may disrupt your original HTML structure and layout.

The reason for this problem is that in the default log content processing flow of WordPress, wpautop (a function that converts carriage returns to p or br tags) runs before Shortcode. So our solution is also very simple. Change their execution order and add the following in the functions.php file of the current topic:

  1. remove_filter( 'the_content', 'wpautop' );
  2. add_filter( 'the_content', 'wpautop' , 12);

Original text: http://blog.wpjam.com/m/solution-to-wordpress-adding-br-and-p-tags-around-shortcodes/

Most of the articles on this site are original and used for personal learning records, which may be helpful to you, for reference only!

 weinxin
My Wechat
Copyright Notice
Please indicate the source and link of the original article reprinted on this site. Thank you for your cooperation!
five hundred and ninety-eight million eight hundred and forty-five thousand and six
 
 Robin
five hundred and ninety-eight million eight hundred and forty-five thousand and six
 anonymous

Comment

Anonymous netizens
 :?:  :razz:  :sad:  :evil:  :!:  :smile:  :oops:  :grin:  :eek:  :shock:  :???:  :cool:  :lol:  :mad:  :twisted:  :roll:  :wink:  :idea:  :arrow:  :neutral:  :cry:  :mrgreen:

Drag the slider to complete validation