Can start be writing in Classic-block when new-posts or new-pages
if add the following code to functions.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
/** * 新規投稿/新規固定ページの時に、クラシック ブロックで書き始められるようにする * 下記のコードを functions.php に追加すると * クラッシク ブロックが1個追加された状態で編集を開始できるようになる * * 動作確認 * WordPress 5.6 * * その他 * Advanced Editor Tools (previously TinyMCE Advanced) プラグインを入れておくと便利 * * See: * https://www.gitmemory.com/issue/WordPress/gutenberg/8379/516985331 * https://github.com/WordPress/gutenberg/issues/8379 * https://github.com/WordPress/gutenberg/blob/master/packages/dom-ready/src/index.js * https://wordpress.stackexchange.com/questions/8257/add-action-hook-for-completely-new-post * https://wordpress.org/support/topic/tinymce-paragraph-block-name/ * https://memo.silverpigeon.jp/how-to-add-gutenberg-block-with-javascript-on-wordpress/ */ add_action('wp_insert_post', function() { add_action('admin_footer', function() { ?> <script> wp.domReady(function () { jQuery(document).ready(function () { var content = "Click here and edit post!"; var name = "tadv/classic-paragraph"; // classic-block insertedBlock = wp.blocks.createBlock(name, { content: content, }); wp.data.dispatch("core/editor").insertBlocks(insertedBlock); }); }); </script> <?php }); }); |
新規投稿/新規固定ページで、下記の状態になる