How can I remove p tags that are auto added within tinymce

前端 未结 11 1914
挽巷
挽巷 2020-12-06 04:46

I am using tinymce 4.0.1 and it automatically adds p tags when you either start typing or hit enter. How can I dynamically remove these p tags and then reinsert the content

11条回答
  •  情书的邮戳
    2020-12-06 04:52

    Insert in theme functions.php the following code:

    add_filter('tiny_mce_before_init', 'my_switch_tinymce_p_br'); 
    
    function my_switch_tinymce_p_br($settings) {
        $settings['forced_root_block'] = false;
        return $settings;
    }
    

    If you want replace root "p" tag with some else, replace false with "div" (for example).

提交回复
热议问题