Title: hooked_block_types
Published: November 8, 2023
Last modified: February 24, 2026

---

# apply_filters( ‘hooked_block_types’, string[] $hooked_block_types, string $relative_position, string $anchor_block_type, WP_Block_Template|WP_Post|array $context )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#wp--skip-link--target)

Filters the list of hooked block types for a given anchor block type and relative
position.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#parameters)󠁿

 `$hooked_block_types`string[]

The list of hooked block types.

`$relative_position`string

The relative position of the hooked blocks.
 Can be one of `'before'`, `'after'`,`'
first_child'`, or `'last_child'`.

`$anchor_block_type`string

The anchor block type.

`$context`[WP_Block_Template](https://developer.wordpress.org/reference/classes/wp_block_template/)
|[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)|array

The block template, template part, post object, or pattern that the anchor block
belongs to.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#source)󠁿

    ```php
    $hooked_block_types = apply_filters( 'hooked_block_types', $hooked_block_types, $relative_position, $anchor_block_type, $context );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/blocks.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/blocks.php#L967)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/blocks.php#L967-L967)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#related)󠁿

| Used by | Description | 
| [set_ignored_hooked_blocks_metadata()](https://developer.wordpress.org/reference/functions/set_ignored_hooked_blocks_metadata/)`wp-includes/blocks.php` |

Adds a list of hooked block types to an anchor block’s ignored hooked block types.

  | 
| [insert_hooked_blocks()](https://developer.wordpress.org/reference/functions/insert_hooked_blocks/)`wp-includes/blocks.php` |

Returns the markup for blocks hooked to the given anchor block in a specific relative position.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.4.0](https://developer.wordpress.org/reference/since/6.4.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/hooked_block_types/?output_format=md#comment-content-7471)
 2.   [HelgaTheViking](https://profiles.wordpress.org/helgatheviking/)  [  2 months ago  ](https://developer.wordpress.org/reference/hooks/hooked_block_types/#comment-7471)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fhooked_block_types%2F%23comment-7471)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fhooked_block_types%2F%23comment-7471)
 4. The following example will insert a custom block after after heading block:
 5.     ```php
        /**
         * Use block hooks to inject the custom block after the heading block
         *
         * @param string                          $hooked_blocks The list of hooked block types.
         * @param string                          $position The relative position of the hooked blocks. Values: 'before', 'after', 'first_child', or 'last_child'.
         * @param string                          $anchor_block The anchor block type.
         * @param WP_Block_Template|WP_Post|array $context The block template, template part, post object, or pattern that the anchor block belongs to.
         * @return string
         */
        function hook_custom_text_after_block( $hooked_blocks, $position, $anchor_block, $context ) {
        	// Check if we're in the 'after' position.
        	if ( $position !== 'after' ) {
        		return $hooked_blocks;
        	}
    
        	// Check if the anchor block is the heading block.
        	if ( $anchor_block !== 'core/heading' ) {
        		return $hooked_blocks;
        	}
    
        	// Add our custom block to be hooked after heading block.
        	$hooked_blocks[] = 'custom/flash-text';
    
        	return $hooked_blocks;
        }
        add_filter( 'hooked_block_types', 'hook_custom_text_after_block', 10, 4 );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fhooked_block_types%2F%3Freplytocom%3D7471%23feedback-editor-7471)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fhooked_block_types%2F)
before being able to contribute a note or feedback.