タイトルそのまま わかる方向けコピペセット
一括設定
funciton.phpに下記記述
add_action('init', function() {
remove_filter('the_excerpt', 'wpautop');
remove_filter('the_content', 'wpautop');
});
add_filter('tiny_mce_before_init', function($init) {
$init['wpautop'] = false;
$init[‘apply_source_formatting’] = true;
return $init;
});
個別設定
の前に下記記述<?php remove_filter('the_content', 'wpautop'); ?>
特定の投稿タイプで設定
add_filter('the_content', 'wpautop_filter', 9);
function wpautop_filter($content) {
global $post;
$remove_filter = false;
//各自設定してね ここから
//特定のカスタム投稿のみ
$arr_types = array('★カスタム投稿タイプ名');
//複数の投稿タイプの場合
$arr_types = array('page','XXX','XXX');
//固定ページのみ
$arr_types = array('page');
//記事ページのみ
$arr_types = array('post');
//各自設定してね ここまで
$post_type = get_post_type( $post->ID );
if (in_array($post_type, $arr_types)) $remove_filter = true;
if ( $remove_filter ) {
remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');
}
return $content;
}