投稿タイプでエディタを切り分ける方法について
-
投稿によって、クラシックエディタとブロックエディタの切り分けを行いたいと思っております。
■ブロックエディタを使用したい投稿タイプ名
・post
・report調べたところ下記コードを「functions.php」に追加すると切り分けができることを知り、試してみたところ、post_typeのif文を1つだけの指定であればうまく切り分けができるのですが、複数指定した場合すべてクラシックエディタで表示されてしまいます。
■切り分けができたコード
add_filter('use_block_editor_for_post_type', 'disable_block_editor', 10, 2); function disable_block_editor($use_block_editor, $post_type) { if ($post_type !== 'post') return false; return $use_block_editor; }
■切り分けができないコード
add_filter('use_block_editor_for_post_type', 'disable_block_editor', 10, 2); function disable_block_editor($use_block_editor, $post_type) { if ($post_type !== 'post' || $post_type !== 'report') return false; return $use_block_editor; }
add_filter('use_block_editor_for_post_type', 'disable_block_editor', 10, 2); function disable_block_editor($use_block_editor, $post_type) { if ($post_type !== 'post' || $post_type !== 'report'){ return false; } return $use_block_editor; }
add_filter('use_block_editor_for_post_type', 'disable_block_editor', 10, 2); function disable_block_editor($use_block_editor, $post_type) { if ($post_type !== 'post'){ return false; } elseif($post_type !== 'report'){ return false; } return $use_block_editor; }
複数指定したい場合はどのように設定したほうが良いのでしょうか。
よろしくお願いいたします。
2件の返信を表示中 - 1 - 2件目 (全2件中)
2件の返信を表示中 - 1 - 2件目 (全2件中)
- トピック「投稿タイプでエディタを切り分ける方法について」には新たに返信することはできません。