Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @rose18
    Yes, it is possible to set the maximum number of columns for the “core/columns” block in WordPress. To do this, you can use the register_block_type function and specify the max_columns attribute in the supports array when registering the block.

    Here is an example of how you can set the maximum number of columns to 3 for the “core/columns” block:

    
    function my_custom_block_registration() {
        // Register the "core/columns" block
        register_block_type( 'core/columns', array(
            'supports' => array(
                'max_columns' => 3,
            ),
        ) );
    }
    add_action( 'init', 'my_custom_block_registration' );
    

    This code should be placed in your theme’s functions.php file or in a custom plugin. After adding this code, the “core/columns” block will only allow a maximum of 3 columns.

    Thread Starter rose18

    (@rose18)

    Thank you @faisalahammad ! When I add that code to my functions.php file, I get this error message:

    Notice: Function WP_Block_Type_Registry::register was called incorrectly. Block type "core/columns" is already registered. Please see Debugging in WordPress for more information.

    Is there a way to fix it?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Limit the columns for core/columns’ is closed to new replies.