Yoast SEO: Use the block editor without the Yoast SEO metabox
In the block editor, Yoast SEO shows its settings in the Yoast SEO sidebar and in the Yoast SEO metabox below the content. By default, both keep their values in hidden form fields inside the metabox.
From Yoast SEO 29.0, the wpseo_disable_metabox_in_block_editor filter removes the metabox from the block editor. The sidebar then keeps the values in the post record of the editor, and WordPress saves them together with the post through the REST API.
The filter returns false by default. It removes the metabox only from the block editor. The classic editor and the term edit screens keep the metabox. The Elementor editor has no metabox, and the filter doesn't change how Yoast SEO works there.
Usage
add_filter( 'wpseo_disable_metabox_in_block_editor', '__return_true' );
Register the callback before the wp_loaded action, for example from a plugin or from the functions.php file of a theme.
Return the same value on every request. Yoast SEO reads the filter when the editor screen loads and on every request during wp_loaded, and the filter passes no post, post type, or screen. If a callback depends on the current screen, user, or post, then saving becomes unreliable.
What changes when the filter returns true
The following changes apply to the block editor:
- Yoast SEO doesn't register the
wpseo_metametabox. The Yoast SEO sidebar is the only place to edit the Yoast SEO settings of a post. - The page doesn't contain the hidden
yoast_wpseo_*form fields. - WordPress saves the Yoast SEO values in the same REST request as the post. The
wpseo_save_compare_dataaction and thewpseo_save_metaboxesfilter don't run. - Hooks that only change the metabox don't apply, because there is no metabox to change:
wpseo_metabox_prioandwpseo_content_meta_section_content.
The following changes aren't limited to the block editor. They apply to every post type that has Yoast SEO post meta in the REST API:
- The
wpseo_saved_postdataaction runs after each REST update of a post. - Yoast SEO adds
custom-fieldssupport to the post type if it uses the block editor and doesn't have that support. With that support, themetaproperty is part of the REST API for the post type, and the WordPress Custom fields panel is available in the editor preferences.
If your plugin reads or writes the hidden form fields, or stores its own values next to the Yoast SEO values, see Make your plugin work with and without the metabox.
WordPress versions
Yoast SEO 29.0 requires WordPress 7.0 or later. In WordPress 7.0, 7.1, and 7.2, if the edit screen has at least one metabox, then the Revisions button opens the classic revisions screen and not the revision view inside the editor.
If the filter returns true, the Yoast SEO metabox no longer causes that. Metaboxes from other plugins still do, and so does the WordPress Custom fields panel when a user turns it on.
Yoast SEO add-ons
The following versions support the filter. Earlier versions expect the hidden form fields.
| Plugin | Version |
|---|---|
| Yoast SEO | 29.0 |
| Yoast SEO Premium | 29.0 |
| Yoast Video SEO | 15.4 |
| Yoast News SEO | 13.4 |
Yoast WooCommerce SEO and Yoast Local SEO aren't in the table, because the filter doesn't change how they work. WooCommerce products don't use the block editor, so the product edit screen keeps the Yoast SEO metabox. Yoast Local SEO has its own metabox.