Use a reusable block in your theme

I ran into a situation where I created a reuseable block for many of the content pages of an e-commerce site. We wanted to use this same block at the bottom of all WooCommerce product pages as well. I could have written custom HTML/CSS for this small banner block but I always love making things editable in a single spot.

Reuseable blocks are saved as Custom Post Types in WordPress. As such, there is an admin page where you can find them. When adding/editing a page, click the “+” used to add a new block, click the “Reusable” tab, then click “Manage all reusable blocks”.

Click on the block you want to include in your theme files to get the unique post ID. Example: https://yourdomain.com/wp-admin/post.php?post=123&action=edit

In your theme template file, use the following code: