I apologize if this has been answered already. I’ve spent several hours searching through the WordPress directories and documentation, and I haven’t been able to find the code for the default Gutenberg blocks. Could anyone point me in the right direction?
To clarify, I am specifically wondering where in the directory tree of a WordPress installation the blocks are defined.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
If your end goal is to have a better understanding of how blocks work, I would encourage to install the gutenberg plugin instead.
The block code within the WordPress installation itself is not intended to be read by end users nor directly modified. It’s minified to save space.
To answer your question, the code is stored in a couple places:
wp-includes/js/dist/block-library.jswp-includes/blocks/
If you wish to modify a core block, like a block style variation where you can modify the CSS of a particular block, do not modify those files, it’s recommended to place your code in a custom plugin that you would make.
(and depending how much you want to modify it, you may want to just create your own block).
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0