Created
September 24, 2020 10:32
-
-
Save munirkamal/1c3cde4ff49b788e2ef9b19a3bc4387e to your computer and use it in GitHub Desktop.
Gutenberg Snippet: Modify the first paragraph block added by default on pages with a custom placeholder text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function custom_paragraph_placeholder_for_pages() { | |
| //Define your post types to lock for classic editor block. Default CPTs are 'post', 'page' | |
| $post_type_object = get_post_type_object( 'page' ); | |
| //Define what blocks you want to lock it for. Here is the list of core blocks: | |
| //https://gist.github.com/munirkamal/0d443605a3273926051c2971d5f3ff84#file-core-blocks-txt | |
| $post_type_object->template = array( | |
| array( 'core/paragraph', array( | |
| 'placeholder' => 'my placeholder...', | |
| ) ), | |
| ); | |
| } | |
| add_action( 'init', 'custom_paragraph_placeholder_for_pages' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment