How AI is applied across API Evangelist and APIs.io. Read my AI disclosure →
API Evangelist API Evangelist
Discovery
Learnings
Guidance
Toolbox
Alignment
API Evangelist LLC

Dynamically loading template parts in block themes

calendar_today June 18, 2026 person Justin Tadlock domain wordpress

This tutorial shows how to avoid duplicating block theme templates by using the render_block_data filter to dynamically swap template parts based on context like post category or page type. A music project example displays different sidebars per category by modifying a template part’s slug on the fly, using get_block_theme_folders() to locate parts and providing automatic fallback when no specific match exists. The approach works for any template part, including headers, footers, and banners.

open_in_new Read original post