Setting Multiple Blocks To False Not Working

Support MB Blocks Setting Multiple Blocks To False Not WorkingResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38041
    Nicholas CoxNicholas Cox
    Participant

    Hi

    I have a few blocks setup and when setting the 'multiple' option to false ('multiple' => false) it does not restrict the block as described here https://docs.metabox.io/extensions/mb-blocks/#multiple I can add more than one block per page/post and save it. Im using WordPress 6.0.1 and latest version of blocks addon.

    add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
    	$meta_boxes[] = [
    		'title'           => 'Product Listing Block',
    		'id'              => 'dc-product-listing-block',
    		'description'     => 'Product listing layouts for your store',
    		'type'            => 'block',
    		'icon'            => 'screenoptions',
    		'category'        => 'dc-blocks',
    		'context'         => 'side',
    		'render_template' => __DIR__ . '/template/dc-product-listing-block-template.php',
    		'supports' => [
    			'align' => ['wide', 'full'],
    		],
    		'keywords' 		  => ['product', 'listing', 'ecommerce'],
    		'multiple' 		  => false,
    		'reusable' 		  => false,
    		'preview' => [
    			'image'       => '', // Image ID
    			'title'       => 'Product Block',
    			'description' => 'Product listing layout block',
    		],
    		'fields' => [
    			[
    				'type' => 'number',
    				'id'   => 'per_page',
    				'name' => 'Posts per page',
    				'min'  => 1,
    				'max'  => 100, //max of 100 (WP API only supports this by default)
    				'required' => true,
    				'std'  => 10, 
    			]
    		],
    	];
    	return $meta_boxes;
    } );
    #38053
    Long NguyenLong Nguyen
    Moderator

    Hi Nick,

    The setting multiple should be added under the supports setting

    'supports' => [
        'align'           => ['wide', 'full'],
        'customClassName' => true,
        'anchor'          => false,
        'multiple'        => false
    ],

    Read more on the documentation https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#multiple

    #38057
    Nicholas CoxNicholas Cox
    Participant

    ah ok my bad, i missed the part on this, thanks for clearing this up.

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