I'm forcing a block template for the editor view of a specific custom post type using basically this example as a guide:
https://developer.wordpress.org/block-editor/reference-guides/block-api/block-templates/#locking
function myplugin_register_template() {
$post_type_object = get_post_type_object( 'post' );
$post_type_object->template = array(
array( 'core/paragraph', array(
'placeholder' => 'Add Description...',
) ),
);
$post_type_object->template_lock = 'all';
}
add_action( 'init', 'myplugin_register_template' );
I was able to set multiple input fields and change their default attributes like their placeholder or content.
What I would love is the ability to add a label in the editor above the input field. The only solution I could find was creating a static block with static text. Awful. I would need to create a block for each label.
I would love a way to set its content from the placeholder or content attribute from the above template definition code but, for the life of me, I can't find any documentation on how to go about it.
so the questions are:
- is there an easier way to set a static label above each field in a template that I'm missing?
- is there a way to implement a label block that takes a content attribute from there?