/blocks
This filter is called when the card builder retrieves available blocks and when a card renders custom blocks.
It allows to add your own blocks in the card builder in order to output custom content with your own markup and logic.
Argument | Type | Description |
$blocks | array | Holds custom block definitions |
[pastacode lang=”php” manual=”function%20prefix_register_block(%20%24blocks%20)%20%7B%0A%0A%09%2F%2F%20’my_block’%20corresponds%20to%20the%20block%20slug.%0A%09%24blocks%5B’my_block’%5D%20%3D%20%5B%0A%09%09’name’%20%3D%3E%20__(%20’My%20Block’%2C%20’text-domain’%20)%2C%0A%09%09’render_callback’%20%3D%3E%20’prefix_my_block_render’%2C%0A%09%5D%3B%0A%0A%09return%20%24blocks%3B%0A%0A%7D%0A%0Aadd_filter(%20’wp_grid_builder%2Fblocks’%2C%20’prefix_register_block’%2C%2010%2C%201%20)%3B%0A%0A%2F%2F%20The%20render%20callback%20function%20allows%20to%20output%20content%20in%20cards.%0Afunction%20prefix_my_block_render()%20%7B%0A%0A%09%2F%2F%20Get%20current%20post%2C%20term%2C%20or%20user%20object.%0A%09%24post%20%3D%20wpgb_get_post()%3B%0A%0A%0A%09%2F%2F%20Output%20the%20post%20title.%20%0A%09echo%20’%3Ch3%3E’%20.%20esc_html(%20%24post-%3Epost_title%20)%20.%20’%3C%2Fh3%3E’%3B%0A%7D” message=”” highlight=”” provider=”manual”/]