Search code examples
wordpress-theming

Why does commented out php code still run on Wordpress themes?


In the home.html file of the twentytwentythree theme, the php code still seems to have an effect on the output:

<!-- wp:template-part {"slug":"header","tagName":"header"} /-->

    <!-- wp:group {"tagName":"main","style":{"spacing":{"margin":{"top":"var:preset|spacing|50","bottom":"var:preset|spacing|70"}}},"layout":{"type":"constrained"}} -->
    
<main class="wp-block-group" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--70)">
        <!-- wp:heading {"level":1,"align":"wide","style":{"spacing":{"margin":{"bottom":"var:preset|spacing|60"}}}} -->

        <h1 class="alignwide" style="margin-bottom:var(--wp--preset--spacing--60)">Mindblown: a blog about philosophy.</h1>
        <!-- /wp:heading -->

Is this standard practice?


Solution

  • This is not PHP, this is the markup used for Blocks by Wordpress starting from 5.9

    As explained here : https://developer.wordpress.org/block-editor/explanations/architecture/key-concepts/

    Blocks are an abstract unit for structuring and interacting with content. When composed together they create the content for a webpage. Everything from a paragraph, to a video, to the site title is represented as a block.

    This is the new way of building WP themes to allow full site editing for users.