Halloween Sale 15% off Ends in See the plans
PHP

Change the Content and Wide Widths of a Block Theme

Sets how wide normal and "wide" content is in your block theme, on the site and in the editor, for example a narrower reading column with wider images.

Don’t have WPIDE yet? Install it on your site

Code

// Width of normal content and of wide-aligned blocks.
$wpide_content_size = '720px';
$wpide_wide_size    = '1200px';

add_filter( 'wp_theme_json_data_theme', function ( $theme_json ) use ( $wpide_content_size, $wpide_wide_size ) {
    return $theme_json->update_with( array(
        'version'  => WP_Theme_JSON::LATEST_SCHEMA,
        'settings' => array(
            'layout' => array(
                'contentSize' => $wpide_content_size,
                'wideSize'    => $wpide_wide_size,
            ),
        ),
    ) );
} );

Notes

Values can be px, rem or %. Changes made in the Site Editor's Styles still take priority.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.