• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • AI Agents
    • OpenClaw
    • Claude Code
    • n8n
    • Hermes Agent
    • Open WebUI
    • Docker
  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
    • Email Hosting
    • HeroicGuard
    • GPU Hosting
    • Website Builder
  • VPS
    • Managed VPS
    • Unmanaged VPS
    • Flex VPS
  • Reseller
  • Gaming
  • Domains
  • Account
  • Blog Home
  • Categories
  • Authors

How To Limit The Selection Of Blocks In Gutenberg

Bhagwad Park

Published on: May 27, 2019

Categories: WordPress 0

When Gutenberg came out, it brought with it, a vastly expanded selection of default content types, we call “blocks”. Previously in the TinyMCE editor, we had buttons at the top, each of which represented a different type of content – headings, lists, and those inserted by plugins. In time though, the developers felt that this was too restrictive, and didn’t accurately represent the way pages are built on the web today.

Gutenberg has a dizzying selection of blocks that we can use. For example, here’s just the starting selection:

Before you Limit the Blocks in Gutenberg WordPress
Lots of Gutenberg Blocks

Some of these like the “Heading” block, have sub-choices that allow us to specify the flavor. For example, we can choose h1, h2, or h3 headings. This works great if you’re the sole editor of your website, and know exactly what to use, and what not to.

How to Prevent Accidental Block Usage

However, if you have a bunch of people contributing to your site, you might want to restrict their access to the wide variety of blocks. A simple reason could be to reduce confusion and streamline the editing process. Another could be that you don’t want to reveal too much of the inner workings of your website to 3rd party authors.

Some blocks can expose table names, or other internal codes used on your site that you want to keep private. So it’s perfectly understandable if you need to limit the blocks that are available by default. In the code below, I’ll show you how to create a “safe” list of blocks for your users, and you can customize in on your own.

Limiting the Number of Available Blocks

Let’s say we want to limit the number of available blocks to the following list:

  • Images
  • Paragraphs
  • Headings
  • Lists
  • Re-usable blocks

To implement this, paste the following code into your functions.php, or the place where you store your custom PHP code. If you’re new to pasting code in WordPress, here’s a tutorial from our knowledge base on how to do just that.

function restrict_blocks( $allowed_blocks, $post ) {
     $allowed_blocks = array(
         'core/block',
         'core/image',
         'core/paragraph',
         'core/heading',
         'core/list'
     );
     return $allowed_blocks;
 }
 add_filter( 'allowed_block_types', 'restrict_blocks');

Once you save your changes and load a new WordPress editing page, you should see the following when you try and insert a new block:

Limited Selection of Gutenberg Blocks
Restrict the number of Gutenberg Blocks

As you can see, the number is greatly restricted. I don’t have any re-usable blocks set up, so it doesn’t show any.

Restricting the Blocks Based on User Role or Page Type

Of course, you don’t want to implement the above code “as is”, since it’ll restrict the blocks for everyone, including yourself. What you want to do, is first check to see if the user is in a particular role. For example, you might want to restrict roles only for Contributors. In which case, the code becomes:

function restrict_blocks( $allowed_blocks, $post ) {
 $user_role = get_queried_object()->roles[0];
 if( in_array( strtolower('Contributor'), $user_role ) )
     $allowed_blocks = array(
         'core/block',
         'core/image',
         'core/paragraph',
         'core/heading',
         'core/list'
     );
     return $allowed_blocks;
 }
 add_filter( 'allowed_block_types', 'restrict_blocks');

You can also filter the blocks based on post types. For example, you may think that regular users who write blog posts don’t need all the fancy block-based bells and whistles, but you might want to keep the option open for pages. In which case you can add another conditional statement like is_page() to get the result you want.

You can expand the above list to further include selected blocks by using this reference list for the default blocks in WordPress 5.0. Based on this, you can make your block selection as comprehensive as you want.

I personally feel that it’s still not as simple as adding or removing functionality in the TinyMCE editor, but it’s a start. Perhaps they’ll add additional functionality to streamline things in the future!

Bhagwad Park Profile Picture
Bhagwad Park

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!

Related Posts

Joomla vs. WordPress: Which One Is Better?

In this post, we’ll consider five differences between Joomla and WordPress and how you might go forward with setting up a WordPress website.

How To Back Up Your WordPress Site (And Why You Should Do It Today)

In this post, we’ll take a closer look at why backups matter. We’ll also show you different ways to back up your WordPress website.

How to Eliminate Render-Blocking Resources in WordPress (& Why You Should)

Many things can slow down your site, including render-blocking resources. These are CSS and JavaScript files that delay the loading of content on your site. As a result, visitors will have to wait longer to interact with your page, which could lead to frustration and instant exits.  So, what can you do to eliminate render-blocking […]

What Is Self-Hosted WordPress?

In this post, we’ll differentiate self-hosted WordPress from WordPress.com, and discuss the benefits of the former.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • OpenClaw Hosting
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • Managed VPS Hosting
  • Unmanaged VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • GPU Hosting
  • Email Hosting
  • HeroicGuard
  • Domains
  • Website Builder
  • AI Agent Hosting
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2026 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA