Summary: Theme features in WordPress 5.8


The release of WordPress 5.8 is planned for July 20, 2021, and is now at release candidate 2.
WordPress 5.8 includes important theme updates. You can test the features with the beta tester plugin.

This post is a summary. See the 5.8 field guide for more information.

The new widget screens are enabled for classic themes

For classic themes, the two widget screens have been updated, and you can place blocks in widget areas:

  • Appearance → Widgets
  • Appearance → Customize → Widgets.

Themes can opt-out of the widget screens by removing the theme support:

remove_theme_support( 'widgets-block-editor' );

Users can opt out of the widget screen by installing the Classic Widgets plugin.

For further information, read the Widgets how to guide in the block editor documentation. 

Block themes do not use widget areas, and the widget screens are not enabled.

You do not need to convert existing widgets to blocks

-At least not for the short term. You can add existing widgets to the widget screens, and you find them under the Widgets category.

Template editing is opt-in for classic themes

Template editing is a new feature where you can create custom page templates with blocks. Templates can be created and edited from the new Template section in the block editor.

Initially, template editing was enabled for all themes. Theme developers raised concerns that they could not update all their existing classic themes to support this new feature. With a late change, the release squad and editor team choose to change the template editing to be opt-in for classic themes. 

To opt-in, include a theme.json file or use the new theme support:

add_theme_support( 'block-templates' );

Classic themes with a theme.json file can opt-out of template editing by removing the theme support: remove_theme_support(  'block-templates' );

Template editing can not be disabled for block themes.

Themes with support for template editing can select the default blocks used in new templates

Themes can include a default block template used for creating new templates in the template editor.

You can add the blocks by filtering defaultBlockTemplate in block_editor_settings_all. 

You can use a file:

add_filter( 'block_editor_settings_all', function( $settings ) {
     $settings['defaultBlockTemplate'] = file_get_contents( get_theme_file_path( 'block-template-default.html' ) );
     return $settings;
});

Or add the markup in the filter:

add_filter( 'block_editor_settings_all', function( $settings ) {
     $settings['defaultBlockTemplate'] = "<!-- wp:paragraph -->
     <p>This is a random template</p>
     <!-- /wp:paragraph -->";

     return $settings;

});

If the theme does not provide defaults, the new template will include:

  • Site title
  • Site tagline
  • Separator
  • Two group blocks
  • Post title
  • Post content

-At the time of writing this, it is still undecided if the feature will be enabled for the default theme.

New options for loading block styles

WordPress 5.8 improves the way block-styles are loaded by introducing 2 new features:

  • Load styles only for rendered blocks in a page
  • Inline small styles

You can opt-in to only load styles for the rendered blocks by using the should_load_separate_core_block_assets filter:

add_filter( 'should_load_separate_core_block_assets', '__return_true' );

You can opt-in to inline styles per-stylesheet basis, and reduce the number of requests when a page is rendered.
To opt-in, add the ‘path’ data to your stylesheet:

wp_style_add_data( $style_handle, 'path', $file_path );

The themes team encourage you to consider page speed and sustainability and take advantage of these new features. Read the dev note by @aristath for more information.

Both classic themes and block themes can use theme.json

Any theme can take advantage of generating CSS custom properties and default settings and styles for blocks using theme.json.

The team is updating the Theme Developer handbook; meanwhile, you can learn about the theme.json format in the block editor handbook. 

Block themes will not work in WordPress 5.8 without Gutenberg installed

In WordPress 5.8, you can only activate block themes with Gutenberg installed. Block themes no longer need to check if Gutenberg is active.

New blocks in 5.8

Site blocks:

  • Site title
  • Site tagline
  • Site logo

Post blocks:

  • Post title
  • Post date
  • Post featured image
  • Post content
  • Post excerpt
  • Post tags -variations of post terms
  • Post categories -variations of post terms

Archive blocks:

  • Archive title

Structural blocks

  • Login / out
  • Page list

Post listing blocks

  • Query Loop, alias Post List
  • Post Template (inner block)
  • Query pagination (Previous page, next page, inner blocks)

Notable name changes

Post Hierarchical Terms (categories) and Post Tags have been reduced from two blocks to one block called Post Terms. The block has one variation for displaying categories and one for tags.

The Query Loop has been renamed to Post Template. The Query block’s label (The name visible in the editor) has been changed to Query Loop.

Changes to the Add Themes screen

The featured tab has been removed from the Add Themes screen in the WordPress admin area. The tabs now match the theme directory.

Thank you @kafleg and @aristath for proofreading.

#themes-team