W3cubDocs

/WordPress

did_action( string $hook_name ): int

Retrieves the number of times an action has been fired during the current request.

Parameters

$hook_namestringrequired
The name of the action hook.

Return

int The number of times the action hook has been fired.

Source

function did_action( $hook_name ) {
	global $wp_actions;

	if ( ! isset( $wp_actions[ $hook_name ] ) ) {
		return 0;
	}

	return $wp_actions[ $hook_name ];
}

Changelog

Version Description
2.1.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/did_action