Summary: Theme features in WordPress 5.8

The release of WordPress 5.8 is planned for July 20, 2021, and is now at release candidateRelease Candidate A beta version of software with the potential to be a final product, which is ready to release unless significant bugs emerge. 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 widgetWidget A WordPress Widget is a small block that performs a specific function. You can add these widgets in sidebars also known as widget-ready areas on your web page. WordPress widgets were originally created to provide a simple and easy-to-use way of giving design and structure control of the WordPress theme to the user. 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 pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party.

For further information, read the Widgets how to guide in the blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. 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 categoryCategory The 'category' taxonomy lets you group posts / content together that share a common bond. Categories are pre-defined and broad ranging..

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.jsonJSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. 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 filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output.:

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 CSSCSS CSS is an acronym for cascading style sheets. This is what controls the design or look and feel of a site. 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 GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/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 imageFeatured image A featured image is the main image used on your blog archive page and is pulled when the post or page is shared on social media. The image can be used to display in widget areas on your site or in a summary list of posts.
  • Post content
  • Post excerptExcerpt An excerpt is the description of the blog post or page that will by default show on the blog archive page, in search results (SERPs), and on social media. With an SEO plugin, the excerpt may also be in that plugin’s metabox.
  • 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 LoopLoop The Loop is PHP code used by WordPress to display posts. Using The Loop, WordPress processes each post to be displayed on the current page, and formats it according to how it matches specified criteria within The Loop tags. Any HTML or PHP code in the Loop will be processed on each post. https://codex.wordpress.org/The_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