Earlier this year, I wrote about how to avoid accidentally editing your reusable blocks in WordPress Gutenberg. However, the new WordPress version 6.0 adds this functionality by default to the WordPress editor, and it comes with some nice perks as well! Here’s how it works.
Locking Blocks in Gutenberg
While the earlier plugin only worked on reusable blocks, the new functionality in WordPress applies to all blocks equally. Just select one, then click the three dots to access the block settings. Here you’ll see a new “Lock” option like this:
This will bring up a screen where you have three options for locking the block:
- Restrict editing
- Disable movement
- Prevent removal
The three options are pretty self-explanatory. The first prevents you from accidentally editing a block, the second disallows using the arrow buttons to move the block up or down, and the third prevents users from deleting it. These are extremely useful for the following scenarios.
1. Restrict Editing Uses
Often when you create a reusable block, you can accidentally make changes to it without noticing. for example, you can hit the “Enter” key, on the last element, thinking that you’re creating a separate paragraph block, but in reality, you’ve just added a new block to the reusable group, and if you save your changes, all the other reusable blocks that you’ve added throughout your site will change as well. This is obviously a serious mistake.
Preventing the editing of a block can also be useful when your content is written by other people and you don’t want them messing with your blocks. These can be calls to action or certain graphics. When you let others edit posts in Gutenberg, you don’t have control over what they do, locking down a block to prevent editing is the best way to ensure nothing changes.
2. Disabling Movement
Disabling the movement of blocks prevents the user from using either shortcut keys or the graphical interface to move blocks up or down. Of course, you can always move or remove other blocks that surround this one, but that takes a lot more effort since the arrows icon disappears when the “Disable movement” option is selected:
Certain items like CTA buttons have a specific place on a page, and disabling their movement ensures that they’re positioned correctly. It makes the most sense to use this when the block is in the middle of two other blocks that shouldn’t be changed. Otherwise, someone can just add new content above or below the locked block and work around the restrictions that way.
3. Prevent Removal
If you have a certain block that’s necessary for legal reasons, you can prevent others from removing it altogether. Disclaimers are a great example of this kind of block that you shouldn’t remove. Affiliate link disclaimers, cookie disclaimers, and more fit into this category. Other examples include author blocks and related meta-information like schemas and more.
Depending on how you structure your site, you need to decide between putting these blocks in a template, or in posts individually. If you choose the latter, it’s a good idea to lock them down and prevent their removal.
The Block Editor Comes Closer to a Page Builder
With the ability to lock blocks, the Gutenberg editor is becoming a hybrid of an editor and a page builder. Soon, ordinary folk will be able to create page templates without any code, and without needing to edit theme files. At this rate, it’s just a matter of time before we’re able to create our own themes without a single line of code!
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
Leave a Reply