• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

I Like Kill Nerds

The blog of Australian Front End / Aurelia Javascript Developer & brewing aficionado Dwayne Charrington // Aurelia.io Core Team member.

  • Home
  • Aurelia 2
  • Aurelia 1
  • About
  • Aurelia 2 Consulting/Freelance Work

A List of WordPress Gutenberg Core Blocks

Wordpress · September 29, 2021

Believe it or not, finding this information in the official WordPress documentation was a nightmare. I had to go through the WordPress codebase itself to find these values.

In a site I am working on, I wanted only to enable specific WordPress Gutenberg blocks. By default, my client will never use a lot of junk, like buttons and page separators that I wanted to disable.

I am using the allowed_block_types hook to create an inclusion list where I specify what blocks I want to enable. You can also add your custom blocks to this list.

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

/**
    * Set allowed block types on pages/posts/CPTs
    */
function theme_allowed_block_types( $allowed_blocks, $post ) {
    if ( ! ( $post instanceof WP_Block_Editor_Context ) ) {
        return $allowed_blocks;
    }

    $allowed_blocks = array(
        'core/freeform',
        'core/video',
        'core/heading',
        'core/image',
        'core/gallery',
        'core/embed',
        'core/table',
        'core/list',
        'core/paragraph',
        'core/pullquote',
        'core/html'
    );

    return $allowed_blocks;
}

A fair warning. If you’re not using WordPress 5.8 or above, the above might cause issues for you.

Here is a list of core Gutenberg block types that can be specified:

  • core/paragraph
  • core/image
  • core/heading
  • core/gallery
  • core/list
  • core/quote
  • core/shortcode
  • core/archives
  • core/audio
  • core/button
  • core/buttons
  • core/calendar
  • core/categories
  • core/code
  • core/columns
  • core/column
  • core/cover
  • core/embed
  • core/file
  • core/group
  • core/freeform
  • core/html
  • core/media-text
  • core/latest-comments
  • core/latest-posts
  • core/missing
  • core/more
  • core/nextpage
  • core/preformatted
  • core/pullquote
  • core/rss
  • core/search
  • core/separator
  • core/block
  • core/social-links
  • core/social-link
  • core/spacer
  • core/subhead
  • core/table
  • core/tag-cloud
  • core/text-columns
  • core/verse
  • core/video

Dwayne

Leave a Reply Cancel reply

6 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Alicia St Rose
Alicia St Rose
1 year ago

Thank you from the bottom of my geeky heart! You saved me loads of time. I even tweeted about this!!

2
Kate Hopkins
Kate Hopkins
1 year ago

This has been super handy, but for some reason it’s not working for core/group or core/spacer (they remain hidden, even when I put them in the allowed blocks list). Any idea why that might be?

0
pandammonium
pandammonium
11 months ago

I don’t understand why the WP documentation is so opaque. Thanks for providing the list of core blocks 😅

0
Stefan
Stefan
11 months ago

Useful list. Question: How can i allow only Youtube and Vimeo?

6
James
James
9 months ago

Legend! You’ve saved me loads of time.

0
Casey Milne
Casey Milne
8 months ago

Official docs may have improved since this was written, https://developer.wordpress.org/block-editor/reference-guides/core-blocks/. This page has the “name” needed for templates, plus some other details.

1

Primary Sidebar

Popular

  • I Joined Truth Social Using a VPN and Editing Some HTML to Bypass the Phone Verification
  • Testing Event Listeners In Jest (Without Using A Library)
  • How To Get The Hash of A File In Node.js
  • Thoughts on the Flipper Zero
  • Waiting for an Element to Exist With JavaScript
  • How To Paginate An Array In Javascript
  • How To Mock uuid In Jest
  • How To Decompile And Compile Android APK's On A Mac Using Apktool
  • How To Get Last 4 Digits of A Credit Card Number in Javascript
  • Wild Natural Deodorant Review

Recent Comments

  • CJ on Microsoft Modern Wireless Headset Review
  • Dwayne on Microsoft Modern Wireless Headset Review
  • CJ on Microsoft Modern Wireless Headset Review
  • john on Microsoft Modern Wireless Headset Review
  • Dwayne on Why You Should Be Using globalThis Instead of Window In Your Javascript Code

Copyright © 2023 · Dwayne Charrington · Log in

wpDiscuz