Discover in this tutorial how to get a list of all the registered blocks of a WordPress installation using code.
In a WordPress installation there may be multiple registered blocks, some added by the WordPress core and others by plugins (and/or themes). Therefore, it is possible that in some cases you may be interested in obtaining a list of all the blocks of a WordPress installation.
With this information you can decide if you prefer some of them not to be shown and unregister them so that they are not displayed in the editor.
Let’s take a look at it:
Steps to get all registered blocks in a WordPress site
1. Go to edit a post
First you have to go to edit an existing post or if you prefer you can create a new one. The important thing is that you are in the backend of a post.
2. Use the browser inspector console
Open the browser inspector (Cmd + Alt + I or Ctr + Alt + I, in most browsers), go to the console section and type:
When you hit enter you will get an array with all the registered blocks. Something like this:
In this screenshot only the first 39 are shown, but the list continued up to 111.
And that’s because in this installation only native blocks and Genesis Blocks are registered.
By the way, if you want to have at hand the list of native blocks, here you have it:
And those of Genesis Blocks:
With this simple trick you can also get the ones from your favorite block collection plugin. 😉
Now you know how to get a list with all the blocks registered in a WordPress installation to decide if you need them all or not.