Title: WP_Block_Type::get_variations
Published: April 3, 2024
Last modified: August 20, 2026

---

# WP_Block_Type::get_variations(): array[]

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_block_type/get_variations/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_block_type/get_variations/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_block_type/get_variations/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_block_type/get_variations/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_block_type/get_variations/?output_format=md#changelog)

Get block variations.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_block_type/get_variations/?output_format=md#return)󠁿

 array[]

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

    ```php
    public function get_variations() {
    	if ( ! isset( $this->variations ) ) {
    		$this->variations = array();
    		if ( is_callable( $this->variation_callback ) ) {
    			$this->variations = call_user_func( $this->variation_callback );
    		}
    	}

    	/**
    	 * Filters the registered variations for a block type.
    	 *
    	 * @since 6.5.0
    	 *
    	 * @param array         $variations Array of registered variations for a block type.
    	 * @param WP_Block_Type $block_type The full block type object.
    	 */
    	return apply_filters( 'get_block_type_variations', $this->variations, $this );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-block-type.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-block-type.php#L600)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-block-type.php#L600-L617)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_block_type/get_variations/?output_format=md#hooks)󠁿

 [apply_filters( ‘get_block_type_variations’, array $variations, WP_Block_Type $block_type )](https://developer.wordpress.org/reference/hooks/get_block_type_variations/)

Filters the registered variations for a block type.

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

| Uses | Description | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

| Used by | Description | 
| [WP_Block_Type::__get()](https://developer.wordpress.org/reference/classes/wp_block_type/__get/)`wp-includes/class-wp-block-type.php` |

Proxies getting values for deprecated properties for script and style handles for backward compatibility.

  |

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

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

## User Contributed Notes

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