Skip to content

Instantly share code, notes, and snippets.

@ravewebdev
Last active July 8, 2020 22:29
Show Gist options
  • Save ravewebdev/b5b4f60707c8c9f5772d2b918fcd706b to your computer and use it in GitHub Desktop.
Save ravewebdev/b5b4f60707c8c9f5772d2b918fcd706b to your computer and use it in GitHub Desktop.
1.2.2. Render static version of block in PHP
<?php
function render_block( array $attributes ) : string {
$id = $attributes['id'];
$class = 'wp-block-rave-initiative-tracker';
ob_start();
?>
<div
class="<?php echo esc_attr( $class ); ?>"
data-id="<?php echo esc_attr( $id ); ?>"
data-post_id="<?php echo esc_attr( get_the_ID() ); ?>"
>
<!-- Your actual block content here... -->
</div>
<?php
return ob_get_clean();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment