Tsuji Note

技術的なことや、日々の出来事で記録しておきたいことを載せます

自動的に<p>タグが挿入されるのを避ける

「<!–handmade–>」というコメントを入れておくと自動的に<p>タグが挿入されなくなるようにした
function rm_wpautop($content) {
    global $post;
    // Get the keys and values of the custom fields:
    if(preg_match('||siu',$content)){

    	remove_filter('the_content', 'wpautop');

    } else {
        add_filter('the_content', 'wpautop');
    }
    return $content;
}
// Hook into the Plugin API
add_filter('the_content', 'rm_wpautop', 9);

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です