JavaScript for WordPress Forums Gutenberg Development Metaboxes question – relation with block vs post object

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #60491
    Lucy Mairin

    Hi Zach,
    Just wanted to make sure I understood correctly metaboxes with Gutenberg, and have an additional question.

    With WP classic editor all post metadata has a relation with the actual post Object. With Gutenberg, even though the metadata is stored in the DB with the same relation to the post id, from your example it looks like in the UI the metadata is related to a specific block and not entirely to the post Object as the way that the metabox only displays when the block is selected and therefor the metabox wouldn’t event be available if the block is never added.

    Wondering if there is a way to have metabboxes render permanently in the Gutenberg editor as you would depend on the user adding a certain block to have the metabox available, which is the way to go in cases where you need mandatory data saved as postmeta?
    Would you need to add a “Metabox Block” with all the required fields by default when you create a new post (assuming this is possible)?


    Zac Gordon

    Great question 🙂

    Technically the metabox is still tied to post object. But if that block is not added, then correct there would not be a value.

    It is possible to use block template to make certain blocks required.

    That is covered in depth in the Gutenberg theme development course, but I have a quick tutorial on it here

    Hope I understood your question correctly and that helps!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.