After upgrading to WordPress 5.5 & trying out the new Gutenberg functionality, we've faced unfortunate 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.

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

Most recently, on one of the client’s website, the above error came up after upgrading my WordPress core.

[08-Sep-2020 22:34:31 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function register_block_type() in /.../wp-content/plugins/my-plugin.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:

function devpeel_load_blocks() {
	
	register_block_type('devpeel-blocks/block-06', array('render_callback' => 'devpeel_render_block_latest_post'));
	
}
add_action('init', 'devpeel_load_blocks');

Fix?

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

You may also Like