Skip to main content
The Web Stories plugin provides several action hooks that allow you to extend and customize its functionality. Action hooks let you execute custom code at specific points during plugin execution.

Plugin Lifecycle

web_stories_activation

Fires after the plugin is activated.
/**
 * @param bool $network_wide Whether the activation was network-wide
 */
do_action( 'web_stories_activation', $network_wide );
Location: includes/namespace.php:56

web_stories_deactivation

Fires after the plugin is deactivated.
/**
 * @param bool $network_wide Whether the deactivation was network-wide
 */
do_action( 'web_stories_deactivation', $network_wide );
Location: includes/namespace.php:131

User Capabilities

web_stories_add_capabilities

Fires when adding custom capabilities to user roles. This hook allows you to add Web Stories capabilities to custom roles.
/**
 * @param array $all_capabilities List of all post type capabilities
 */
do_action( 'web_stories_add_capabilities', $all_capabilities );
Location: includes/User/Capabilities.php:172

web_stories_remove_capabilities

Fires when removing custom capabilities from user roles. Useful for cleaning up capabilities from custom roles.
/**
 * @param array $all_capabilities List of all post type capabilities
 */
do_action( 'web_stories_remove_capabilities', $all_capabilities );
Location: includes/User/Capabilities.php:204

Story Rendering

web_stories_story_head

Fires in the story <head> section. Use this to add custom meta tags, scripts, or styles to individual story pages.
// No parameters
do_action( 'web_stories_story_head' );
Location: includes/Renderer/Story/HTML.php:167
The plugin automatically hooks several WordPress functions to this action, including:
  • rest_output_link_wp_head
  • wp_resource_hints
  • feed_links
  • rel_canonical
  • wp_site_icon
  • wp_oembed_add_discovery_links
  • wp_robots

web_stories_print_analytics

Fires before the closing </amp-story> tag. Use this to add custom analytics configuration or other content that needs to appear inside the story element.
// No parameters
do_action( 'web_stories_print_analytics' );
Location: includes/Renderer/Story/HTML.php:216
The plugin’s built-in Analytics service uses this hook to add Google Analytics tracking when configured in the settings.

Filter Hooks

Explore filter hooks for modifying data and behavior

Story Post Type

Learn about the Story post type structure

Build docs developers (and LLMs) love