Displays the title of the current post's parent post. Useful in hierarchical post type templates.
block.json defines an example with level 4 and isLink false — inserter preview.
prc-block/post-parent-title
theme
| Feature | Enabled |
|---|---|
| Align | wide, full |
| HTML | No |
| Color (background) | Yes |
| Color (text) | Yes |
| Color (gradients) | No |
| Color (link) | Yes |
| Spacing (margin) | Yes |
| Spacing (padding) | Yes |
| Typography (fontSize) | Yes |
| Typography (lineHeight) | Yes |
| Typography (fontFamily) | Yes |
| Typography (fontWeight) | Yes |
| Typography (fontStyle) | Yes |
| Typography (textTransform) | Yes |
| Typography (textDecoration) | Yes |
| Typography (letterSpacing) | Yes |
| Attribute | Type | Default | Description |
|---|---|---|---|
textAlign |
string |
-- | Text alignment for the heading (left, center, right). |
level |
number |
4 |
The heading level (1-6) for the rendered tag. |
isLink |
boolean |
false |
Whether to wrap the title in a link to the parent post. |
rel |
string |
"" |
The rel attribute for the link (e.g., noopener). |
linkTarget |
string |
"_self" |
Link target. Either _self or _blank. |
| Context | Description |
|---|---|
postId |
The current post ID |
postType |
The current post type |
queryId |
The query loop ID (if in a query) |
No block style variations defined.
None.
None, but requires a post context (typically used in post templates or query loops).
- Insert the Post Parent Title block in a post template or query loop context.
- The block automatically looks up the parent post of the current post and displays its title.
- Use the Heading Level dropdown in the toolbar to change the heading tag (h1-h6, default h4).
- Use the Alignment control to set text alignment.
- In the Inspector Panel > Settings:
- Toggle Make title a link to wrap the title in an anchor tag pointing to the parent post.
- When linked, toggle Open in new tab and set a custom Link rel attribute.
- If the current post has no parent, the block renders nothing on the frontend (shows "No parent post found" in the editor).
<h4 class="wp-block-prc-block-post-parent-title has-text-align-center">
<a href="https://example.com/parent-post/" target="_self"
>Parent Post Title</a
>
<div
data-wp-interactive="prc-block/table-of-contents"
class="prc-post-parent-title__active-toc-part"
>
<span data-wp-text="state.currentlyActivePartLabel"></span>
</div>
</h4>Without link:
<h4 class="wp-block-prc-block-post-parent-title">
Parent Post Title
<div
data-wp-interactive="prc-block/table-of-contents"
class="prc-post-parent-title__active-toc-part"
>
<span data-wp-text="state.currentlyActivePartLabel"></span>
</div>
</h4>The render_block_callback method:
- Returns empty if no
postIdin block context. - Gets the parent post ID via
wp_get_post_parent_id(). - Returns empty if no parent or no parent title.
- Determines the heading tag from the
levelattribute (defaulth4). - If
isLinkis true, wraps the title in an<a>tag with the parent's permalink, target, and rel attributes. - Appends a
prc-post-parent-title__active-toc-partdiv that integrates with theprc-block/table-of-contentsInteractivity API store to display the currently active section label.
The block itself has no dedicated view script, but the rendered markup includes an Interactivity API binding to prc-block/table-of-contents for displaying the currently active table-of-contents part label.
core/post-title-- Displays the current post's own titleprc-block/table-of-contents-- Provides the active section label shown in the parent title block