Is it possible to include a custom Gutenberg block in a Wordpress theme. So that I doesn't have to upload two separate parts: Theme and a plugin with the Gutenberg block.
I have already tried to create a subfolder with the Gutenberg plugin inside the theme and include this one in the functions.php file of my theme. But that didn't work.
I see that you're a new contributor; welcome!
The following should work: Put the PHP that registers the block in the theme's functions.php file. You'll have to write a function that hooks into the init action and does the following:
That template file, which you would put in the theme alongside functions.php or in a sub-folder, will use JSX to format your block.
Of course, the details of what you code depend on what you want your block to do. I strongly suggest you go through the official Gutenberg Block Tutorial from WordPress.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With