Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Yes, this is standard practice in WordPress theme development. The home.html file you provided is likely a template file for the home page of a WordPress website using the TwentyTwentyThree theme. This template file is a mix of HTML and WordPress-specific syntax that is used by WordPress to generate the final HTML output.

The block is used to indicate a reusable template part that can be used in multiple templates, and the and blocks are used to define blocks in the WordPress block editor, which is a powerful feature that allows users to create and customize page layouts visually.

The var(–wp–preset–spacing–50) and var(–wp–preset–spacing–70) are CSS variables that are set by the theme’s PHP code. This allows the PHP code to dynamically set the values of these variables based on the theme’s settings, which can then be used in the HTML and CSS to ensure consistency throughout the website.

Overall, this is a common and recommended practice in WordPress theme development as it allows for greater flexibility and easier maintenance of the theme code.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading