Guide

Story Item

Block Overview

PropertyValue
Nameprc-block/story-item
TitleStory Item
Categorycontent-curation
Version5.0.0
DescriptionA story item is a visual display of a post, with a title, excerpt, and image. Pre-compiled variations such as pub-listing and list-item are available for each post.
Keywordsprc, story, item, story item, stub

Supports

FeatureEnabled
HTML editingNo
Spacingmargin (top/bottom), padding
Bordercolor, width
TypographyfontSize, fontFamily
InteractivityclientNavigation

Attributes

AttributeTypeDefaultDescription
titlestring(none)The story item headline.
excerptstring(none)HTML excerpt content. Serialized from the .description container (source: html in block.json). In the editor, edited with RichText on a div.description; when the header is disabled, the excerpt also gets a sans-serif class for typography.
urlstring""Link URL for the story item.
labelstring(none)Meta label (e.g., "Report", "Fact Sheet").
datestring(none)Publication date string (formatted as "M j, Y").
imagestring(none)Image URL for the story item.
imageSlotstring"top"Image position. Options: top, left, right, bottom, disabled.
imageSizestring"A1"Image size preset (e.g., A1, A2, A3).
isChartArtbooleanfalseWhether the image is chart art (affects rendering).
postIdinteger(none)The WordPress post ID to pull data from.
postTypestring(none)The WordPress post type.
headerSizeinteger2Heading level for the title (1-6).
enableAltHeaderWeightbooleanfalseUse alternative (lighter) header font weight.
enableHeaderbooleantrueWhether to show the title.
enableExcerptbooleantrueWhether to show the excerpt.
enableExtrabooleanfalseWhether to show the extra content slot (inner blocks).
enableMetabooleantrueWhether to show the meta section (label, date).
metaTaxonomystring"formats"Which taxonomy to use for the meta label.
isPreviewbooleanfalseWhether the block is in preview/read-only mode.

Uses Context

Context KeyDescription
postIdPost ID from query loop context.
postTypePost type from query loop context.
queryQuery parameters from query loop.
queryIdQuery loop ID.
enhancedPaginationWhether enhanced pagination is enabled.
displayLayoutLayout settings from query loop.
previewPostTypePost type for preview mode.
grid/column/desktop/spanGrid column span for desktop.
grid/column/tablet/spanGrid column span for tablet.
grid/column/mobile/spanGrid column span for mobile.

Grid columns and --grid-column-gap

When a story item sits inside prc-block/grid-column, the column block exposes --grid-column-gap on its wrapper (from the column’s block spacing block gap, vertical axis). Descendant story-item styles can use that variable so vertical padding and dividers between stacked items stay aligned with the column’s gap.

In style.scss, consecutive story items in several containers (including grid columns with layout flow, post template list items, and related selectors) use:

  • padding: var(--grid-column-gap, 21px) 0 (with a 21px fallback when the variable is absent), plus bottom border treatment between items and first/last/only-child exceptions.

So changing the column’s block gap in the editor updates spacing for those story-item stacks without duplicating values in theme CSS.

Available Styles

None defined in block.json.

Block Variations

VariationTitleDescriptionKey Attributes
story-item-ledeLede Story ItemDefault lede layout: top A1 image with header and excerpt.imageSlot: "top", imageSize: "A1", headerSize: 1
story-item-publication-listingPublication Listing Story ItemLeft A3 image (right on mobile).imageSlot: "left", imageSize: "A3", headerSize: 2
story-item-list-itemList ItemNo excerpt, no image.imageSlot: "disabled", enableExcerpt: false

All variations are available in the inserter, block settings, and transform scopes.

Inner Blocks

When enableExtra is true, accepts inner blocks in the "extra" slot. Allowed blocks: core/list, core/paragraph, core/html.

Parent / Ancestor Requirements

None. Can be placed anywhere, including inside query loops (core/post-template).

Transforms

Supports transforming from raw pasted content:

  • If a <p> tag contains a URL matching the current site domain, it transforms into a prc-block/story-item block with that URL. This runs at priority 0 (before any other transforms).

Usage Instructions

  1. Insert the Story Item block.
  2. If no postId is set, a Placeholder appears with a search field to find and select a post.
  3. Once a post is selected, the block populates title, excerpt, image, date, and label from the post data.
  4. Use the toolbar and inspector controls to configure:
    • Image slot: top, left, right, bottom, or disabled.
    • Image size: A1 (large), A2 (medium), A3 (small).
    • Header size: Heading level 1-6.
    • Toggle sections: Enable/disable header, excerpt, meta, and extra content.
    • Meta taxonomy: Choose which taxonomy provides the label.
  5. When placed inside a Query Loop (core/post-template), the block automatically adapts to each post in the loop using query context.
  6. When a linked post is selected and WP AI is enabled (PRCStoryItemAI.enabled), use the toolbar Generate with AI control to draft a title or excerpt from the linked post content.
  7. Click the block to enter edit mode; deselect to see the preview.

AI generation (optional)

When @prc/wp-ai is active, Story_Item_AI registers abilities prc-ai/generate-blurb and prc-ai/generate-title. The editor modal (ai-generate.jsx) uses @prc/components useAISuggest to populate title and excerpt from the linked postId.

Block Markup Example

<article
	class="wp-block-prc-block-story-item is-style-lede has-image-top has-image-size-a1"
>
	<div class="meta">
		<span class="label">Report</span>
		<span class="date">Jan 1, 2023</span>
	</div>
	<div class="image loaded">
		<a href="https://example.com/article">
			<img src="https://example.com/image.jpg" alt="Article title" />
		</a>
	</div>
	<h2 class="title">
		<a href="https://example.com/article">Article Title</a>
	</h2>
	<div class="description">
		<p>Lorem ipsum dolor sit amet...</p>
	</div>
</article>

PHP Rendering

The block is server-side rendered via Story_Item::render_story_item():

  • Instantiates a Story_Item_API object that handles all rendering logic.
  • Produces four markup sections: meta, image, title, and content (excerpt + extra).
  • Wraps everything in an <article> tag with block wrapper attributes.
  • Supports query context awareness via handle_story_item_query_context_awareness():
    • When inside a core/post-template, the block receives queryId and query context.
    • Removes postId and postType from hoisted context so each iteration uses its own post data.
  • Uses object caching for logged-out, non-preview requests (story-item-v1 group, 1-hour TTL). Cache keys include attributes, inner content hash, and a per-post version bumped on prc_platform_on_update.
  • Empty or invalid dates no longer render as epoch timestamps.
  • Date format: M j, Y (e.g., "Jan 1, 2023").

Frontend Interactivity

The view.js script adds a loaded CSS class to all .image elements within story items after the window load event, enabling CSS transitions for image appearance.

  • prc-block/grid-column — Parent can supply --grid-column-gap for stacked story items (see above).
  • core/post-template — Can be placed inside query loops for dynamic post listing.
  • core/query — Provides query context when story items are used in loops.

Was this helpful?