How to re-use a block

Adding a post or a page is a one-off exercise — you will normally start from a blank page (though I have in mind an exploration of template pages, but that is for the future). But everyone has bits of content to be re-used: we have our disclaimer which goes at the bottom of each of our public pages. In the old days of printing, there would be boilerplate texts to be dropped into the matrix wherever needed (the classic would be the newspaper masthead).

In WordPress, all your pages and posts are made up of blocks: a block could be a paragraph, a bullet-list, an image, or many other options. The Media-with-text block is used in our walk listings, but let’s leave that until later in this page.

Once you have created content, look at each block carefully. If you are going to need that block again,

  • Use the three dots at the right-hand side of the hovering format menu.
  • Select Add to reusable blocks.
  • Give it a useful short name, using hyphens to indicate hierarchy (this is crucial to block management — see below).
  • Save it.

At this point, I must declare a hyphen of my own. Although the WordPress word is reusable, I shall use re-usable. This avoids any chance that a reader, and especially a text-to-speech reader, may drift towards Germany and read the pronunciation as “royssable”. The Americans, curiously for a people of multiple immigrancies, have little respect for language confusion.

Block management and nomenclature

Unfortunately, WordPress does not have the concept of block hierarchy, so we need to create a shadow hierarchy, using consistent nomenclature. This may be seen most clearly in the path listings, where there are three main divisions. Thus,

  • the listing for each “walk collection” — a long path with linear subsections which qualify as Green Walks — begins with “seq-” (for sequence). Thus, the Don Valley Way’s listing block is “seq-donv”.
  • the listing for each “individual walk” — a one-day Green Walk — begins with “walk-“. Thus the Polish Air Force Heritage Trail’s listing block is “walk-pafht”.
  • the listing for each guided/group walking organisation begins with “gg-“. Thus the Saturday Walkers Club’s listing block is “gg-swc”.

This allows us to search while managing the re-usable blocks (it’s an option on the three-dot menu above the Page/Block tabs of the right-hand menu). Keep the block names short: blanks within names are not allowed, and we don’t want short essays as block names.

Re-using a block

When you need the text, image, or whatever again, just select the named re-usable block from the green + sign (you can filter to choose from only re-usable blocks), and in it goes.

So, I hear the words of the comfortless, why not just copy and paste? Because when you have a re-usable block, if you change the content of the block (from anywhere it is used), the content is updated everywhere it is used, without your having to chase round updating each instance. The updating includes links, so if you add, delete or change a link, that action percolates through all instances. This makes it really powerful.

Blocks of blocks

The Media-with-text block is even more exciting. We use this block type in the walk listings. So why the excitement? This block is actually a block of blocks: the image, the heading, and the text beneath the heading. The heading and text can be edited to generate even more blocks as part of the re-usable block. Using each entry as a re-usable block means that we can generate filtered lists (though not as automatically as filtering posts by category), and maintain consistency when a walk touches more than one region (the Epping Forest Centenary Walk may start at Wanstead Flats, but it is not solely a London walk. Once the block has been created in the London list, it is the work of a few seconds to add it to the England East list (or any other relevant list): just find the green + sign between the blocks where you want to slot it in, and search the block selector by block name.

What else?

Is there no end to the flexibility of re-usable blocks? I don’t know, but I do know that one can break a single instance away from the re-usable block so that it is different from other instances. I also know that if all links in a re-usable block are internal (i.e., only use block anchors without full URLs), that block will work on any files with the same block anchors. I use that trick for the jumps to walk collections, individual walks, and guided/group walks in our lists.