• Resolved ursulaniamh

    (@ursulaniamh)


    I just discovered that WP will pre-populate a custom post type page with selected blocks using ‘template’:

    …..
    ‘rewrite’ => array(‘slug’ => ‘superfoods/articles’, ‘with_front’ => true),
    ‘show_in_rest’ => true,
    ‘menu_position’ => 6,
    ‘supports’ => array(‘post’, ‘title’, ‘editor’, ‘thumbnail’, ‘excerpt’),
    ‘template’ => array(
    array( ‘core/image’, array(
    ‘align’ => ‘left’,
    ) ),
    array( ‘core/paragraph’, array(
    ‘placeholder’ => ‘Add Description…’,
    ) ),
    ….

    Is it possible to add a custom blockLab block in this way ?

    I made a BlockLab block called bloggrid.

    So the syntax might be:

    ‘template’ => array(
    array( ‘BlockLab/bloggrid ),
    )

    except that the above didn’t work.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ryan Kienstra

    (@ryankienstra)

    Hi @ursulaniamh,
    Thanks for asking, interesting question.

    Could you try:

    
    ‘template’ => array(
            array( ‘block-lab/bloggrid' )
    ...
    
    

    Block Lab blocks have the namespace of block-lab/. Though I’m still not sure it’ll work for CPTs.

    Thread Starter ursulaniamh

    (@ursulaniamh)

    yep, that worked…

    ‘template’ => array(
    array( ‘core/image’, array( ‘level’ => ‘5’, ‘align’ => ‘wide’),
    array( ‘core/paragraph’, array( ‘level’ => ‘5’,’className’ => ‘float-test-para’ ) ),
    array( ‘block-lab/bloggrid’, array(‘level’ => ‘5’) )
    )

    Plugin Author Ryan Kienstra

    (@ryankienstra)

    Oh nice!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘BlockLab via custom post type args….’ is closed to new replies.