Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/pewresearch/prc-block-area-modules/archive/refs/heads/trunk.zipNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
Canonical docs: docs/plugins/prc-block-area-modules/
Provides an editorially curated system for populating named zones in a block theme with reusable block content. Rather than using static template parts, editors assign a block_module post (a freeform block-editor document) to a named block_area taxonomy term, optionally scoped by taxonomy (e.g., topic category or region). The correct module is resolved server-side at render time.
What it does
- Registers the
block_modulecustom post type — full block-editor documents that serve as slot content. - Registers the
block_areahierarchical taxonomy, used to tag modules to named zones (e.g.,topic-lede,featured-banner). - Provides the
prc-platform/block-areablock, which resolves and renders the matchingblock_moduleat request time based onblockAreaSlug+ optional taxonomy term. Supports directrefoverride to pin a specific module. - Supports
inheritTermFromTemplateso a single block area placed in a taxonomy archive template automatically scopes to the current term. - Provides the
prc-platform/block-area-context-providerblock (dev/layout use), which wraps block areas and query blocks. It pre-fetches the_story_item_idsfrom all enclosed block modules and injects them aspost__not_ininto sibling query blocks, preventing story repetition on the same page. - On
pre_get_posts, automatically excludestopic-ledestory items from the main query on category archives. - Caches resolved
_story_item_idsper block-area/category combination (1 hour TTL, object cache). Cache is busted onblock_modulesave. - Stores an indexed list of
prc-block/story-itempost IDs (_story_item_idsmeta) on eachblock_moduleat save time. - Ships four block variations:
Topic Block Area(bycategory),Regions Countries Block Area(byregions-countries),Collections Block Area(bycollection), andNewsletter List Block Area(byprc_newsletter_list). - Block area editor UI includes a setup wizard (for first-time configuration) and an
InnerBlocksAsSyncedContentview of the resolved module with inspector controls for re-pointing the area. - Non-menu block areas are suppressed on paged requests (
is_paged()). The Interactivity API store (prc-platform/block-area) mirrors this behavior on the frontend.
Key files
| File | Purpose |
|---|---|
prc-block-area-modules.php |
Plugin entry point; defines constants, loads dependencies, fires run_prc_block_area_modules() |
includes/class-content-type.php |
Registers block_module post type, block_area taxonomy, _story_item_ids post meta + REST field, and story-item ID extraction on save |
includes/class-plugin.php |
Wires Content_Type, Block_Area, and Block_Area_Context_Provider into the loader |
src/block-area/block.json |
Block metadata for prc-platform/block-area (attributes, supports, usesContext) |
src/block-area/class-block-area.php |
Server render callback; resolves matching block_module via WP_Query, outputs Interactivity API wrapper |
src/block-area/edit.jsx |
Editor UI — setup wizard on first use, InnerBlocksAsSyncedContent once a module is linked |
src/block-area/variations.js |
Four block variations scoped by taxonomy (category, regions-countries, collection, prc_newsletter_list) |
src/block-area/view.js |
Interactivity API store — hides non-menu block areas on paged requests |
src/block-area-context-provider/class-block-area-context-provider.php |
Collects story item IDs from block modules, injects into query block context and main query |
src/block-area-context-provider/block.json |
Block metadata for prc-platform/block-area-context-provider |
src/block-area/hooks/use-block-modules.js |
Hook for fetching block_module posts in the editor by block area + taxonomy term |
src/block-area/hooks/use-taxonomy-info.js |
Hook for resolving term/area names and IDs from slugs |
src/block-area/block-area-wizard/ |
Multi-step editor wizard (intro → select/query → create) for initial block area setup |
Filters / hooks
| Hook | Type | Direction | Description |
|---|---|---|---|
init |
Action | Consumed | Registers block_module post type, block_area taxonomy, post meta, and both blocks |
rest_api_init |
Action | Consumed | Registers the _story_item_ids REST field on block_module |
render_block_context (priority 1) |
Filter | Consumed | construct_block_context — finds the first prc-platform/block-area inside the context provider and pre-fetches its story item IDs |
render_block_context (priority 100) |
Filter | Consumed | execute_block_context — injects collected story item IDs into core/post-template query context as post__not_in |
pre_get_posts |
Action | Consumed | On category archive main queries (non-paged, non-front-page), excludes topic-lede story items from results |
prc_platform_on_block_module_update |
Action | Consumed | Two callbacks: (1) re-indexes _story_item_ids from block content, (2) busts the object-cache entry for the module's block area + category |
the_content |
Filter | Consumed | Applied to resolved block_module post content during prc-platform/block-area render |
Data model
block_module (post type)
└── block_area (taxonomy) – which zone this module fills
└── category / regions-countries / collection / prc_newsletter_list (taxonomies) – optional scoping term
└── _story_item_ids (post meta) – indexed array of prc-block/story-item postIds
A prc-platform/block-area block resolves to the single block_module post that matches:
block_areaterm slug ==blockAreaSlug- (optional) scoping taxonomy term ==
taxonomyTermSlugor current queried term wheninheritTermFromTemplateis true - Or directly via
ref(post ID), bypassing taxonomy lookup entirely
Usage notes
- Template usage: Place
prc-platform/block-areain a block theme template. SetblockAreaSlugto the zone name (e.g.,topic-lede),taxonomyNametocategory,regions-countries,collection, orprc_newsletter_list, and enableinheritTermFromTemplateso the block resolves automatically per archive term. - Repetition prevention: Wrap block areas and downstream query blocks inside
prc-platform/block-area-context-provider. The provider ensures posts already displayed in a module's story items are excluded from sibling query loops. - Cache invalidation: Object cache entries are keyed by
md5(json([blockAreaSlug, categorySlug]))under theprc_block_area_module_story_item_idsgroup. Cache TTL is 1 hour. Saving ablock_moduledeletes its specific cache entry. - Paged suppression: Block areas without
menuin their slug return no content on paged requests (?paged=2, etc.), both server-side and via the Interactivity API store.
Dependencies
- Requires:
prc-platform-core - PHP: 8.2+
- WordPress: 6.7+
- JS runtime:
@wordpress/interactivity,@prc/components(InnerBlocksAsSyncedContent)
Build
npm run build -w @prc/block-area-modules