WordPress 文章內的 br 元素被 wpautop 吃掉時該如何解決?

將 wpautop 關閉

function custom_disable_wpautop_for_posts($content) {
  global $post;

  if (is_single()) {
    remove_filter('the_content', 'wpautop');
    remove_filter('the_excerpt', 'wpautop');
  }

  return $content;
}
add_filter('the_content', 'custom_disable_wpautop_for_posts', 0);