Custom Fields
Re-Envisioned
Support MB Blocks How can I use MB-Blocks as template registered post type?

This topic contains 5 replies, has 2 voices, and was last updated by  closemarketing 1 month ago.

  • Creator
    Topic
  • #16510
    Resolved
    closemarketing
    Participant

    Hello,
    I’d like to force to use the block in a registered post type. I can use template argument in register_post_type, but it seems that is not working.

    Is it possible?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #16529

    Anh Tran
    Keymaster

    Hello,

    I’m not sure what you meant. If a post has block editor enabled, then all the registered blocks are available. Or did you mean to set the default content for a post of a specific post type? I found a post on this topic, but not sure if that works for Gutenberg.

    #16539

    closemarketing
    Participant

    Hello in register_post_type, you can have block templates. It should be nice to have as default the block in a post type:

    ‘template’ => array( ‘layout/name-block’ ),
    ‘template_lock’ => ‘all’,

    But I’m not sure which values use in template.

    Regards.

    #16579

    Anh Tran
    Keymaster

    I got it.

    The custom blocks registered with MB Blocks have id meta-box/{$block_id}. So you can define your post type template like:

    'template' => ['meta-box/hero', 'meta-box/team-member']
    
    #16597

    closemarketing
    Participant

    Very nice!!!

    Thanks!

    #16598

    closemarketing
    Participant

    I get a blank page when i use the template…

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.