Ben
Ben is a lifelong Nintendo fan who likes to build websites, and make video games. He buys way too much Lego.
WordPress and Games
Early on in the development of the new Gutenberg editor I asked how to get a list of all the blocks available in the new editor, then today Keith Devon asked how to do it on Twitter. So I thought I would post the answer here.
To get a list of all the WordPress Blocks currently available in your Post/ Page editor you should open up the browser console and then enter the following:
wp.blocks.getBlockTypes()
The output looks something like this:
This will list all blocks, the core ones, and the ones added by plugins. It’s particularly handy for WordPress plugin developers, but will also be useful when setting properties in theme.json
a new feature that is part of the upcoming Full Site Editing functionality of WordPress.
Super useful, thanks! Do you know if there’s anything similar for Block Patterns?
Thanks – glad it’s useful. I’m afraid I haven’t been able to work out anything similar to get a list of patterns.
Hello , sorry for writing this here i hope you will answer me.
I would like to ask about one of your old games Eridani \ Gunwing.
Is there still any way to buy it or download it for free?
Gun wing happened to me one of those childhood game demos that i wanted to buy but never could.
Why isn’t it on the Binary Sun website like the others?
I would give half a limb for a copy.
thank you for your time and patience in advance.
also please keep writing these tutorials are amazing.
Hi Matthew – Eridani/ Gun Wing was made by another developer so I don’t actually have any ownership of it. As such I can’t give it away I’m afraid. Sorry about that.
Hello. Thank you for this – it would be very useful to have a list of the blocks in play & their name spaces (for setting properties in theme.json as you noted).
I feel like I must be doing something run here, though, as I’ve tried running `wp.blocks.getBlockTypes()` in both Chrome & Firefox and get the following:
Firefox:
`Uncaught TypeError: wp.blocks is undefined
debugger eval code:1`
Chrome:
`Uncaught TypeError: Cannot read properties of undefined (reading ‘getBlockTypes’)
at :1:11`
Is there something obvious I’m doing wrong? (Your help & insight is appreciated, but in no way expected – I fully realize there are much better things you could be tending to.)
Hi – I’ve just checked and it still works, so the thing to check is that you are doing this in the block editor. It will only work when the Gutenberg editor is loaded. If you’re doing that then I am not sure what the problem might be I’m afraid.
THANK YOU, Ben! My apologies – it definitely does work! My mistake was that I was running this in the console on the frontend of the site (not within the Gutenberg editor/backend). Thank you for the clarification & for taking the time to check on this.