Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save munirkamal/1c3cde4ff49b788e2ef9b19a3bc4387e to your computer and use it in GitHub Desktop.

Select an option

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
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