Skip to content

DC37 Blocks plugin

Custom block plugin - lives at web/app/plugins/dc37-blocks. This plugin defines the following custom blocks:

Archives (by Post Type)

dc37-blocks/archives-post-type

Renders a date-based archive list or dropdown for any registered public post type. Uses the standard WordPress wp_get_archives() function under the hood, so archive links are generated automatically from published post dates.

Attributes

Attribute Type Default Description
postType string "post" The post type to generate archives for
displayAsDropdown boolean false Render as a <select> dropdown instead of a list
showLabel boolean true Show or hide the label above the archive list/dropdown
showPostCounts boolean false Display the number of posts next to each archive entry
type string "monthly" Grouping — yearly, monthly, weekly, or daily
customLabel string "" Override the default "Archives for {Post Type}" label

Benefits Sidebar

dc37/benefits-sidebar

A sticky "On This Page" sidebar navigation for benefit post type pages. On render it parses the post content, finds all core/details blocks inside the first core/columns block, and builds an anchor link list from their <summary> text.

The front-end script handles two additional behaviours:

  • Hash links — if the page is loaded with a URL hash (e.g. #dental), it automatically opens the matching <details> element
  • Click handling — clicking a sidebar link opens the corresponding <details> element if it is collapsed

This block only renders on pages with post type benefit. It outputs nothing on all other post types.


Locals Accordion

dc37/locals-accordion

Renders all union locals organised by division. Each division is output as a <section> with a heading and optional description and phone number pulled from division taxonomy term meta. Each local within the division is rendered as a native <details> / <summary> element, showing the local number, name, and full post content when expanded.

The block queries locals per division using a transient-cached WP_Query (transient key: division_locals_{slug}). Locals within the same division share a name attribute so only one can be open at a time (native <details> exclusive group behaviour).

The front-end script auto-opens and scrolls to a local if the page URL contains a matching hash (e.g. #1549).

Depends on helper functions from the dc37-architecture plugin: dc37_divisions_terms(), dc37_division_locals_query(), dc37_format_phone_for_tel().


Locals Sidebar

dc37/locals-sidebar

A sticky "On This Page" sidebar navigation that lists all division taxonomy terms as anchor links. Intended to be used alongside the Locals Accordion block — the links jump to the corresponding division <section> headings rendered by that block.

Depends on dc37_divisions_terms() from the dc37-architecture plugin.


dc37/sidebar-nav

A generic "On This Page" sidebar navigation that auto-generates its link list from h2 headings in the current post content. It recursively walks the block tree (including nested blocks) to find all core/heading blocks at the h2 level, extracts their id attribute and text, and renders them as anchor links in document order.

Renders nothing if the current post has no h2 headings with IDs.


Timeline

dc37/timeline

Renders a timeline of events. Supports wide and full alignment. Content is managed directly in the block editor — the block has no server-side render and no custom attributes beyond alignment. Styling is applied via the block's stylesheet.


Query Search block

dc37-blocks/query-search

A search input and submit button for filtering posts. Designed to work inside a Query Loop block or within a block template that uses the main WordPress query. Built on the WordPress Interactivity API.

The block renders a labelled form with a text input and submit button. On submit it constructs a URL parameter in the format query-{queryId}-search and navigates to the updated URL. A pre_get_posts hook in the plugin reads that parameter and applies it as the search term (s) before the main query executes.

Context Behaviour
Query Loop with enhancedPagination: true WP Interactivity Router — partial page replace, no full reload
Query Loop with inherit: true (main archive query) Full page navigation — pre_get_posts filters the main query
Outside any Query Loop Full page redirect to searchDestination URL, or native WP ?s= search

Attributes

Attribute Type Default Description
label string "Search" Visible label above the input
showLabel boolean true Show or hide the label
placeholder string "Search…" Input placeholder text
buttonText string "Search" Submit button label
searchDestination string "" Redirect URL when used outside a Query Loop

Technical notes

  • GET parameter format: query-{queryId}-search (e.g. ?query-1-search=climate)
  • The pre_get_posts handler in dc37-blocks.php matches this pattern via regex and sets the WP query s parameter
  • Uses viewScriptModule (ES module) and data-wp-interactive directives — requires WP 6.5+
  • Navigation is triggered on explicit form submit only (button click or Enter key) — no debounce, no spinner