Title: wp_interactivity_get_context
Published: February 24, 2026

---

# wp_interactivity_get_context( string $store_namespace = null ): array

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_interactivity_get_context/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_interactivity_get_context/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_interactivity_get_context/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_interactivity_get_context/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_interactivity_get_context/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_interactivity_get_context/?output_format=md#changelog)

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

Gets the current Interactivity API context for a given namespace.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_interactivity_get_context/?output_format=md#description)󠁿

The function should be used only during directive processing. If the `$store_namespace`
parameter is omitted, it uses the current namespace value on the internal namespace
stack.

It returns an empty array when the specified namespace is not defined.

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

 `$store_namespace`stringoptional

The unique store namespace identifier.

Default:`null`

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

 array The context for the specified store namespace.

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

    ```php
    function wp_interactivity_get_context( ?string $store_namespace = null ): array {
    	return wp_interactivity()->get_context( $store_namespace );
    }
    ```

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

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

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

Retrieves the main [WP_Interactivity_API](https://developer.wordpress.org/reference/classes/wp_interactivity_api/) instance.

  |

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

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

## User Contributed Notes

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