Book Sale! Code WP2025 takes 20% OFF our Pro Plugins & Books »
Web Dev + WordPress + Security

Fix Gutenberg Errors

I’ve been exploring WordPress new Gutenberg functionality, and unfortunately keep encountering various weird errors. So to keep things organized and hopefully help others on the same path, I’m going to update this post with any Gutenberg errors for which I am able to find a solution. This includes any PHP errors, warnings, notices, as well as any JavaScript and/or debug/console errors.

To save time, I sometimes abbreviate Gutenberg as a numeronym: G7G or g7g.

PHP Fatal error: Uncaught Error: Call to undefined function register_block_type()

First up, the following error:

[26-Mar-2018 22:34:31 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function register_block_type() in /.../wp-content/plugins/whatever.php:111

From what I could find about this surprising error, it’s a known bug that will be fixed in a future update of Gutenberg. For those who want to resolve the issue now, here is a workaround..

The error above is related to calling the following tag directly:

register_block_type('g7g-blocks/block-06', array('render_callback' => 'g7g_render_block_latest_post'));

So look for any instances of code where register_block_type() is used, and replace with this:

function g7g_load_blocks() {
	
	register_block_type('g7g-blocks/block-06', array('render_callback' => 'g7g_render_block_latest_post'));
	
}
add_action('init', 'g7g_load_blocks');

Basically the idea here is to call register_block_type() only via the init hook, instead of just calling directly in the plugin source.

Surely, there are more errors (and solutions) to come! ;)

About the Author
Jeff Starr = Creative thinker. Passionate about free and open Web.
SAC Pro: Unlimited chats.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
WP Themes In Depth: Build and sell awesome WordPress themes.
Thoughts
Finally finished my ultimate block list to stop AI bots :) Blocks over 100 AI bots!
After 10 years working late at night, my schedule has changed. I am now a “morning person”, starting my day at 6am or earlier.
Nice update for Wutsearch search engine launchpad. Now with 19 engines including Luxxle AI-powered search.
New version of 8G Firewall (v1.4) now available for download :)
Wishing everyone a prosperous and bright New Year!
I disabled AI in Google search results. It was making me lazy.
Went out walking today and soaked up some sunshine. It felt good.
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.