WordPressのpost_typeを指定してビジュアルエディタを無効にする

概要説明

記事、固定ページ、カスタム投稿などpost_typeを指定してビジュアルエディタを無効にするカスタマイズ。ライターさんにビジュアルでディタを使ってほしくない、ビジュアルエディタ自体を使用していない場合もこちらで対応が可能です。

post_typeを指定してビジュアルエディタを無効にする

functions.php
/*----------------------------------------------------
 post_typeを指定してビジュアルエディタを無効にする
----------------------------------------------------*/
if ( !function_exists( 'disable_visual_editor' ) ){
    function disable_visual_editor( $wp_rich_edit ) {
        $post_type = get_post_type();

        // 無効にしたい post_type を指定
        $disable_post_type = array('post','page', 'news'); // 投稿,固定ページ,カスタム投稿
        if ( in_array($post_type, $disable_post_type) ) {
            return false;
        } else {
            return $wp_rich_edit;
        }
    }
    add_filter( 'user_can_richedit', 'disable_visual_editor' );
}

WordPress Developer Resources

関連機能

  1. 管理画面右上のヘルプを非表示にする

  2. WordPress管理画面 各種投稿一覧の先頭にIDを表示させデフォルトをIDの降順で表示させるように設定する

  3. WordPress 管理画面ダッシュボードから更新ボタンを押したタイミングを最終更新日としてページに表示させる

サイドバー

よく使うカスタマイズ

最近の記事

アニメの名言集

あまり強い言葉を使うなよ
弱く見えるぞ

BLEACH
by 藍染惣右介

Profile

PAGE TOP