Blockstudio's price is set to rise to 199€ on November 1st. Purchase now to secure the current rate.

Initialization

Last modified:

Block templates will only be executed when the block is rendered. This is enough for most blocks, however, sometimes you need to execute code during an earlier stage of execution. For example, you may want to register a new post type or do some other type of setup unrelated to the block.

To do this, you can add an init.php file to your block directory. This file is executed during the init action. For more information on this specific stage, see the WordPress documentation.

Any init.php file that is found within the block directory will be executed, regardless if it is part of a block context or not. This makes it perfect for organizing code snippets that are not related to any certain blocks.

🍪 This website uses cookies to ensure you get the best experience on our website.

Accept Decline