Build classic and block WordPress themes from scratch: the template hierarchy, The Loop, the_title() and the_content(), template parts, menus, the Customizer, child themes and theme.json.
Lessons
In a block theme, templates are HTML files of block markup — and blocks such as wp:post-title and wp:post-content do exactly what <?php the_title(); ?> and <?php the_content(); ?> do in a classic PHP template.
| Classic PHP | Block markup |
|---|---|
get_header() | <!-- wp:template-part {"slug":"header"} /--> |
the_title() | <!-- wp:post-title /--> |
the_content() | <!-- wp:post-content /--> |
the_post_thumbnail() | <!-- wp:post-featured-image /--> |
the_excerpt() | <!-- wp:post-excerpt /--> |
get_the_date() | <!-- wp:post-date /--> |
| The Loop | <!-- wp:query --> with <!-- wp:post-template --> |
the_posts_pagination() | <!-- wp:query-pagination --> |
get_footer() | <!-- wp:template-part {"slug":"footer"} /--> |
If you have worked through the classic lessons, you already know what every one of these blocks does.
<!-- wp:group {"tagName":"header","layout":{"type":"flex","justifyContent":"space-between"}} -->
<header class="wp-block-group">
<!-- wp:site-title {"level":0} /-->
<!-- wp:navigation /-->
</header>
<!-- /wp:group --><!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:group {"tagName":"main","layout":{"type":"constrained"}} -->
<main class="wp-block-group">
<!-- wp:post-title {"level":1} /-->
<!-- wp:post-date /-->
<!-- wp:post-featured-image {"align":"wide"} /-->
<!-- wp:post-content {"layout":{"type":"constrained"}} /-->
<!-- wp:post-terms {"term":"post_tag"} /-->
<!-- wp:comments /-->
</main>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->The template hierarchy is the same as in lesson 5 — only the file extension changes. templates/single.html renders posts, templates/page.html renders pages, templates/archive.html renders archives.
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:query {"queryId":1,"query":{"inherit":true}} -->
<div class="wp-block-query">
<!-- wp:post-template -->
<!-- wp:post-featured-image {"isLink":true} /-->
<!-- wp:post-title {"isLink":true} /-->
<!-- wp:post-excerpt /-->
<!-- /wp:post-template -->
<!-- wp:query-pagination -->
<!-- wp:query-pagination-previous /-->
<!-- wp:query-pagination-numbers /-->
<!-- wp:query-pagination-next /-->
<!-- /wp:query-pagination -->
<!-- wp:query-no-results -->
<!-- wp:paragraph -->
<p>No posts found.</p>
<!-- /wp:paragraph -->
<!-- /wp:query-no-results -->
</div>
<!-- /wp:query -->
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->"inherit":true is the key setting. It tells the Query block to use the page's main query — the same posts the classic Loop would show — rather than running a custom one.
The fastest and safest workflow is to design in the Site Editor, then export:
templates/ and parts/ files.Watch out: Once someone edits a template in the Site Editor, their version is stored in the database and overrides your file. If your file changes seem to do nothing, check Appearance → Editor for a customised template and reset it.
parts/header.html, parts/footer.html and templates/single.html for gdc-blocks.templates/index.html with an inheriting Query block.In accordance with Section 6 & Section 7 of the DPDP Act 2023, third-party analytics and marketing trackers are strictly gated behind your affirmative consent. You may withdraw consent at any time under Section 6(4).
Essential for session authentication (ci_session), Cross-Site Request Forgery security (csrf_cookie_name), and Cloudflare DDoS/bot prevention. Cannot be disabled.
Gated under DPDP Section 7. Allows Google Analytics 4 (Google Consent Mode v2) to measure aggregate, anonymized tool usage.
Enables browser local storage to preserve your theme selection (dark/light mode) and code editor layout between visits.
Used to display developer sponsorships and native tool partner notices.