{"id":80,"date":"2024-10-03T12:35:55","date_gmt":"2024-10-03T16:35:55","guid":{"rendered":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/?page_id=80"},"modified":"2025-10-20T14:23:12","modified_gmt":"2025-10-20T18:23:12","slug":"render","status":"publish","type":"page","link":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/handbook\/wp-core\/block-architecture\/render\/","title":{"rendered":"render.php (Frontend Template)"},"content":{"rendered":"\n<p>The&nbsp;<code>render.php<\/code>&nbsp;file (or any other file defined in the&nbsp;<a href=\"https:\/\/developer.wordpress.org\/block-editor\/reference-guides\/block-api\/block-metadata\/#render\"><code>render<\/code><\/a>&nbsp;property of&nbsp;<code>block.json<\/code>) defines the server-side process that returns the markup for the block when there is a request from the front end. If defined, this file will take precedence over other ways to render the block\u2019s markup on the front end.<\/p>\n\n\n\n<p>Note: <code>render.php<\/code> is only used by Dynamic Blocks. None of the block\u2019s markup is saved to the database. Instead, its attributes are written inside the block indicator comment. The render method is called to create the block\u2019s markup whenever a front-end user visits the page. This differs from Static Blocks, who store their entire markup in the database.<\/p>\n\n\n\n<p>These render methods automatically receive attribute and inner content information. They can also get additional required dynamic site information \u2013 post lists, comments, taxonomy information, etc.<\/p>\n\n\n\n<p>Alternatively, the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/register_block_type\/\">block registration function<\/a> includes a render_callback argument. As the recommended practice is to register a block type using the metadata stored in the&nbsp;<code>block.json<\/code>&nbsp;file, we will not cover this method.<\/p>\n\n\n\n<h2>Example<\/h2>\n\n\n<article class=\"wp-block-r3-id-documentation-code-prism\">\n\tError: Unable to fetch https:\/\/raw.githubusercontent.com\/bu-ist\/r3-id-documentation\/refs\/heads\/develop\/src\/blocks\/tutorial-01\/render.php<\/article>\n\n\n\n<h2>Overriding<\/h2>\n\n\n\n<p>The output of a block can be modified with <code>php<\/code> using either the <code><a href=\"https:\/\/developer.wordpress.org\/reference\/hooks\/render_block_this-name\/\">render_block_{$this-&gt;name}<\/a><\/code> or <code><a href=\"https:\/\/developer.wordpress.org\/reference\/hooks\/render_block\/\">render_block<\/a><\/code> filters. <\/p>\n\n\n\n<p class=\"has-pale-pink-background-color has-background\">@todo embed an example<\/p>\n\n\n\n<h3>Further Reading<\/h3>\n\n\n\n<ul><li><a href=\"https:\/\/developer.wordpress.org\/block-editor\/getting-started\/fundamentals\/file-structure-of-a-block\/#render-php\">WordPress Developer Resources: File structure of a block<\/a><\/li><li><a href=\"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/best-practices\/dynamic-vs-static\/\">Dynamic vs Static<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The&nbsp;render.php&nbsp;file (or any other file defined in the&nbsp;render&nbsp;property of&nbsp;block.json) defines the server-side process that returns the markup for the block when there is a request from the front end. If defined, this file will take precedence over other ways to render the block\u2019s markup on the front end. Note: render.php is only used by Dynamic [&hellip;]<\/p>\n","protected":false},"author":3670,"featured_media":0,"parent":98,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"status-is-a-reserved-term":[5],"assignee":[4],"_links":{"self":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/80"}],"collection":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/users\/3670"}],"replies":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/comments?post=80"}],"version-history":[{"count":11,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/80\/revisions"}],"predecessor-version":[{"id":743,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/80\/revisions\/743"}],"up":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/98"}],"wp:attachment":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"status-is-a-reserved-term","embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/status-is-a-reserved-term?post=80"},{"taxonomy":"assignee","embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/assignee?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}