WordPress
指定されたテキストに含まれる 2 連続の改行を HTML のパラグラフへ置き換えます(<p>...</p>)。 WordPress はこの関数を投稿や固定ページの本文と抜粋のフィルターに使用します。(Codex日本語版)
remove_filter('the_excerpt', 'wpautop'); remove_filter('the_content', 'wpautop'); remove_filterの説明はこちら。第1引数に対象となるフィルターフック、第2引数にコールバック関数を入れます。(第3もあるけどオプションなので省略)
add_filter('the_content', 'wpautop_filter'); //上述のremove_filterの逆ですね function wpautop_filter($content) { global $post; $remove_filter = false; $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; }
$arr_types = array('page');
add_filter('the_content', 'wpautop_filter'); function wpautop_filter($content) { global $post; $remove_filter = false; $arr_types = array('カスタム投稿タイプを入力'); $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; }以上です。