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. WordPressの管理画面に任意のページ(内容はhtmlにて自由に調整可能)を追加する

  2. WordPress REST API を無効化 ( 管理者ログイン時、Contact Form 7 プラグイン利用時は有効 )

  3. WordPressのバージョン情報を非表示にする

[amazon_auto_links id="695"]

サイドバー

よく使うカスタマイズ

最近の記事

アニメの名言集

天才は嫌いだ
積み重ねたものの美しさが無い

葬送のフリーレン
by リュグナー

Profile

PAGE TOP