wordpressの記事が勝手にpタグ、brの改行が入る
- 公開日:
- 更新日:
- 文字数:773文字
WordPressで自分でhtmlタグを付与して記事を書いてる人からするとこの機能はとても目障りでしょうがないですよね。
そこでpタグ、brの改行をされないようにするコードです。
使用しているthemeのfunctions.phpに下記コードを記述してください。
add_action('init', function() {
remove_filter('the_title', 'wptexturize');
remove_filter('the_content', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
remove_filter('the_title', 'wpautop');
remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');
remove_filter('the_editor_content', 'wp_richedit_pre');
});
add_filter('tiny_mce_before_init', function($init) {
$init['wpautop'] = false;
$init['apply_source_formatting'] = ture;
return $init;
});
参考文献
https://webkikaku.co.jp/blog/wordpress/wordpress-automatic-forming-control/
