Friday, March 14, 2025
HomeEveryday WordPressHow to disable and lock Gutenberg blocks

How to disable and lock Gutenberg blocks


Gutenberg makes it easy to build content with blocks, but sometimes, you need control over which blocks are available. Maybe you’re working on a client site and want to prevent them from using certain blocks. Or perhaps you’re streamlining the editing experience by removing unnecessary options.

In this guide, we’ll explore different ways to disable Gutenberg blocks, including:

  • Using the WordPress user interface (UI) to hide blocks in the inserter
  • Locking blocks to prevent them from being moved or deleted
  • Enforcing block restrictions with PHP, including role-based access

That said, we won’t be covering block visibility (showing/hiding content based on conditions) or disabling specific block settings like text or background colors, which is handled in theme.json. However, we will discuss block locking since it’s closely related to disabling blocks.

All the methods in this guide work without plugins and apply to any block-based theme. Let’s get started!

Disabling blocks with the WordPress UI

Removing unnecessary blocks helps streamline the editing experience and can slightly improve backend performance, as disabled blocks are not loaded into memory.

Any user can disable blocks from the Preferences menu in the block editor. You can do this by clicking the three-dot Settings (⋮) menu in the top-right corner opens the editor preferences. Then, under the Blocks tab, users can uncheck any block to remove it from the block inserter.

For example, you can disable the Quote block by simply unchecking its box, as shown below.

A view of the Block Preferences modal shows the Quote block as being disabled.

If you want to go further, you can disable an entire block category. For instance, unchecking the Text category will remove all text-related blocks from the inserter, ensuring they are no longer available for use. This can be helpful for streamlining the editor and preventing users from accessing unnecessary blocks.

Block Preferences modal
A view of the Block Preferences modal shows the Text category being disabled.



Source link

RELATED ARTICLES
Continue to the category

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Most Popular

Recent Comments