# Registering a block from your theme

> The plugin registers the blocks of ugly-blocks/ by itself. You can also do it with WordPress' own function, from functions.php:

Source: https://uglydev.com/docs/blocks/registering-a-block-from-your-theme/
Updated: 19 November 2026

```php
add_action( 'init', function () {
	register_block_type( get_theme_file_path( 'ugly-blocks/hero' ) );
} );
```

The block gets its fields and its drawing the same way, and it is not registered twice.

> **Important:** this only works for a folder of `ugly-blocks/` whose `block.json` is called `ugly/<folder>`. Any other block (another folder, or another name) is not touched.
