Skip to content

Apologies for the appearance of the site. I'm designing in public!

A jumble of foam numbers

Gutenberg Components - "I only need one"

Published on Friday, 12 April 2019.
At 217 words, this article should take about 1 minute to read.
This article is more than 3 years old.

Gutenberg comes with an awful lot of default components (see list below) most of which will never be used in our websites.

It's perfectly possible to just leave them there but this has the potential for disaster.

Leaving them visible to the content manager raises two possibilities;

  1. It will be difficult for them to find the actual component they want to use
  2. They will try to use a component that we haven't styled which will break the layout on the frontend

So, what do we do...?

Only show the components you will actually use

Drop this into your functions.php file or, better yet, write a plugin to handle it 😎

add_filter('allowed_block_types', 'txb_allowed_block_types', 10, 2);

function txb_allowed_block_types( $allowed_blocks, $post )
{
$allowed_blocks = array(
'core/image', // Add the blocks you want here...
'core/paragraph',
'core/heading',
'acf/videum' // Add your custom blocks here
);

return $allowed_blocks;

}

Gutenberg Default Components


Fin

Comments

In almost all cases, the comments section is a vile cesspool of Reply Guys, racists, and bots.

I don't want to have to deal with that kind of hell so I don't have a comments section.

If you want to continue the conversation, you can always hit me up on Mastodon (which is not a vile cesspool of Reply Guys, racists, and bots).

onward-journeys module