Skip to content

Instantly share code, notes, and snippets.

@diggeddy
Created August 4, 2025 13:25
Show Gist options
  • Select an option

  • Save diggeddy/f6a28f21ce071a6db7f970f2f82cd8a3 to your computer and use it in GitHub Desktop.

Select an option

Save diggeddy/f6a28f21ce071a6db7f970f2f82cd8a3 to your computer and use it in GitHub Desktop.
classic theme - enable block spacing
add_filter( 'wp_theme_json_data_theme', function( $theme_json ) {
$new_data = array(
'version' => 3,
'settings' => array(
'spacing' => array(
// default gap between sibling blocks
'blockGap' => '1.5rem',
// enable per-block margin and padding controls
'margin' => true,
'padding' => true,
// define which units users can choose in the UI
'units' => array( 'px', 'rem', '%', 'em', 'vh', 'vw' ),
// optional: a spacing scale / presets to surface in the UI
'spacingScale' => array(
'0.25rem',
'0.5rem',
'1rem',
'2rem',
'4rem',
),
),
),
);
return $theme_json->update_with( $new_data );
} );
@diggeddy
Copy link
Author

diggeddy commented Aug 4, 2025

Want the Position prorperty:

add_filter( 'wp_theme_json_data_theme', function( $theme_json ) {
    $new_data = array(
        'version'  => 3,
        'settings' => array(
            'position' => array(
                'sticky' => true,
            ),
        ),
    );

    return $theme_json->update_with( $new_data );
} );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment