Experimenting With Reusable Blocks to Create Post Templates

For the past several years, I’ve used the Post Template plugin developed by Vincent Prat to create and manage post templates. For example, some of the information in the WordPress Weekly and In Case You Missed It posts never changes and instead of manually entering it each time, it’s nice to use a template where only a few changes are necessary.

The other day, I was wondering if I could use the reusable block feature in Gutenberg to replace the plugin. Justin Tadlock reached out and provided me a reusable block template JSON file that I imported into Gutenberg. By the way, if you successfully import a block into WordPress, the block won’t appear until you manually refresh the page.

The reusable block template approach works fairly well. However, I noticed that I was unable to add a block inside the reusable block. When I tried, a red line was displayed and any blocks that were inserted were removed.

Red Means No

I understand that reusable blocks are meant to be restricted templates where changes are distributed across a site to wherever the block is displayed. But it’s still a bummer that I can’t add a block inside the template for a singular purpose if a need arises.

One other thing I noticed is that reusable blocks are custom post types. While there is a link to manage them within the reusable block selector, there isn’t a dedicated item within the admin menu. Unless you know the location of the management link, adding and managing them can be a bit more time-consuming.

If you want a quick shortcut to the reusable block management screen, add this to the URL after your domain name. wp-admin/edit.php?post_type=wp_block

I think I’ll experiment with reusable blocks a bit more but as long as they’re not changing often, I believe they’ll make a nice replacement for the Post Templates plugin. What use cases have you encountered where reusable blocks were the solution?

Would you like to write for WP Tavern? We are always accepting guest posts from the community and are looking for new contributors. Get in touch with us and let's discuss your ideas.

9 Comments


  1. It was explained to me that converting the template into individual blocks is a nice workaround if you need to tweak the template for a specific post.

    Report

    Reply

    1. Exactly – you have to convert it to a regular block ! Also, even though Reusable Blocks are CPTs as you mentioned they are not available for exporting from the tools menu. You can only export one Reusable Block at a time, which is pain if you have dozens of them. The mass export functionality was there with the Gutenberg Plugin used with WP 4.9x. When WP 5.0 came around, this disappeared. I reported the issue on Slack and whoever responded, were surprise that exporting from the tools menu is not available. That was in December, here we are 6 months later, and nothing is done…

      It’s ok though, someone created the plugin “fabrica-reusable-block-instances” which not only gives you the option to export all Reusable Blocks at once, but also, it shows you where each Reusable Block is been used, which is very useful, especially when you are deleting those blocks…

      Anyone suggesting to include these 2 functionalities to the core will be total waste of time and frustration…

      Report

      Reply

      1. Actually suggesting anything to the core is since a year or so a total waste of time for “non-regular” “outsiders”, we tried, we know, kthxbye.

        Report


    2. Yes, a reusable block is like global block with specific configuration. When we need to change it for a specific post, we need to duplicate it and change the configuration. In Gutenberg, duplication a reusable block means converting it to a normal block.

      Report

      Reply

  2. Jeff, thank you!

    This may not be the sexiest topic ever but it is very important to me! My not too techie clients need simple and cheap to set up options. So far I see reusable blocks as a great solution.

    Please write more on this topic as you use this feature further!

    Report

    Reply

  3. “While there is a link to manage them within the reusable block selector, there isn’t a dedicated item within the admin menu. Unless you know the location of the management link, adding and managing them can be a bit more time-consuming.”
    You also have it in the main menu: https://imgur.com/a/BF8i4oh

    “I noticed that I was unable to add a block inside the reusable block, it’s still a bummer that I can’t add a block inside the template for a singular purpose if a need arises”
    You can, converting it to a regular block. That’s logical and easy for me. Screenshot: https://imgur.com/a/REqKvf4

    Report

    Reply

  4. We also thought it was silly that there wasn’t a menu for the Reusable Blocks, so we added one:

    add_action( ‘admin_menu’, function () {
    if ( ( current_user_can( ‘edit_posts’ ) ) ) {
    add_menu_page(
    __( ‘Reusable Content Blocks’, ‘domain’ ),
    ‘Reusable Blocks’,
    ‘edit_posts’,
    ‘edit.php?post_type=wp_block’,
    ”,
    ‘dashicons-controls-repeat’,
    21
    );
    }
    } );

    Report

    Reply

    1. Thanks for the code. Now I can offer preset blocks to my clients.

      The problem is that the add_menu_page() function doesn’t work with edit.php?post_type=, because it always appends admin.php. I solved the problem by adding it as a submenu for my theme settings panel.

      Report

      Reply

  5. I would supply 20 or 30 .json files with Reusable Blocks and the theme admin would be able to use them in their posts or pages.

    How could I import them programatically on theme activation?

    Report

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.