Skip to main content
The Web Stories plugin provides numerous filter hooks that allow you to modify data, settings, and behavior throughout the plugin. Filter hooks let you intercept and modify values before they’re used.

Story Metadata & Discovery

Controls whether the document title is printed in the story head.
$enable
bool
default:"true"
Whether to print the document title
Example
add_filter( 'web_stories_enable_document_title', function( $enable ) {
    // Disable document title for stories
    return false;
} );
Location: includes/Discovery.php:123
Controls whether the meta description is printed in the story head.
$enable
bool
default:"true"
Whether to print the meta description
Example
add_filter( 'web_stories_enable_metadata', function( $enable ) {
    // Keep default behavior
    return $enable;
} );
Location: includes/Discovery.php:151
Controls whether Schema.org structured data is printed in the story head.
$enable
bool
default:"true"
Whether to print Schema.org metadata
Example
add_filter( 'web_stories_enable_schemaorg_metadata', '__return_false' );
Location: includes/Discovery.php:173
Controls whether Open Graph meta tags are printed in the story head.
$enable
bool
default:"true"
Whether to print Open Graph metadata
Example
add_filter( 'web_stories_enable_open_graph_metadata', function( $enable ) {
    // Disable if another SEO plugin is active
    if ( defined( 'WPSEO_VERSION' ) ) {
        return false;
    }
    return $enable;
} );
Location: includes/Discovery.php:197
Controls whether Twitter Card meta tags are printed in the story head.
$enable
bool
default:"true"
Whether to print Twitter metadata
Example
add_filter( 'web_stories_enable_twitter_metadata', '__return_true' );
Location: includes/Discovery.php:222
Filters the Schema.org structured data for a story.
$metadata
array
required
The structured data array
$post
WP_Post|null
The current post object if available
Example
add_filter( 'web_stories_story_schema_metadata', function( $metadata, $post ) {
    // Add custom schema properties
    $metadata['keywords'] = get_post_meta( $post->ID, 'story_keywords', true );
    $metadata['author']['url'] = get_author_posts_url( $post->post_author );
    
    return $metadata;
}, 10, 2 );
Location: includes/Discovery.php:372
Filters the Open Graph metadata array for a story.
$metadata
array
required
Array of Open Graph meta tags
$post
WP_Post|null
The current post object
Example
add_filter( 'web_stories_story_open_graph_metadata', function( $metadata, $post ) {
    // Add custom Open Graph tags
    $metadata['og:video'] = get_post_meta( $post->ID, 'story_video_url', true );
    $metadata['og:locale'] = get_locale();
    
    return $metadata;
}, 10, 2 );
Location: includes/Discovery.php:479
Filters the Twitter Card metadata array for a story.
$metadata
array
required
Array of Twitter meta tags
$post
WP_Post|null
The current post object
Example
add_filter( 'web_stories_story_twitter_metadata', function( $metadata, $post ) {
    // Customize Twitter card
    $metadata['twitter:creator'] = '@yourusername';
    $metadata['twitter:site'] = '@yoursite';
    
    return $metadata;
}, 10, 2 );
Location: includes/Discovery.php:519

Publisher & Branding

Filters the publisher name displayed in stories.
$name
string
default:"get_bloginfo('name')"
The publisher name
Example
add_filter( 'web_stories_publisher_name', function( $name ) {
    return 'My Custom Publisher Name';
} );
Location: includes/Model/Story.php:156
Filters the publisher logo size (width and height) for a story.
$size
array
Array containing width and height [width, height]
$story_id
int
The story post ID
Example
add_filter( 'web_stories_publisher_logo_size', function( $size, $story_id ) {
    // Ensure minimum dimensions
    if ( $size[0] < 96 ) {
        return [ 96, 96 ];
    }
    return $size;
}, 10, 2 );
Location: includes/Model/Story.php:415

Story Rendering & Display

Filters the list of sharing providers in the story sharing dialog.
$providers
array
required
Array of sharing provider configurations
Example
add_filter( 'web_stories_share_providers', function( $providers ) {
    // Add WhatsApp sharing
    $providers[] = [
        'provider' => 'whatsapp',
    ];
    
    // Add custom sharing option
    $providers[] = [
        'provider' => 'custom',
        'shareEndpoint' => 'https://example.com/share',
    ];
    
    return $providers;
} );
Location: includes/Renderer/Story/HTML.php:255
See amp-social-share documentation for available provider options.
Filters the CSS classes applied to a single story container.
$classes
array
required
Array of CSS class names
Example
add_filter( 'web_stories_renderer_single_story_classes', function( $classes ) {
    $classes[] = 'my-custom-story-class';
    
    if ( is_user_logged_in() ) {
        $classes[] = 'user-logged-in';
    }
    
    return $classes;
} );
Location: includes/Renderer/Stories/Renderer.php:612
Filters the inline styles applied to the story container.
$styles
array
required
Array of CSS property => value pairs
Example
add_filter( 'web_stories_renderer_container_styles', function( $styles ) {
    // Add custom container styles
    $styles['max-width'] = '800px';
    $styles['margin'] = '0 auto';
    
    return $styles;
} );
Location: includes/Renderer/Stories/Renderer.php:635

Editor & Dashboard

Filters the settings passed to the story editor.
$settings
array
required
Array of editor settings
Example
add_filter( 'web_stories_editor_settings', function( $settings ) {
    // Customize editor settings
    $settings['capabilities']['canUploadFiles'] = current_user_can( 'upload_files' );
    $settings['features']['customFeature'] = true;
    
    return $settings;
} );
Location: includes/Admin/Editor.php:494
Filters the REST API paths to preload in the editor.
$preload_paths
array
required
Array of REST API endpoint paths
$post
WP_Post
The story post object
Example
add_filter( 'web_stories_editor_preload_paths', function( $preload_paths, $post ) {
    // Add custom endpoint to preload
    $preload_paths[] = '/wp/v2/my-custom-endpoint';
    
    return $preload_paths;
}, 10, 2 );
Location: includes/templates/admin/edit-story.php:153
Filters the meta boxes available in the story editor.
$meta_boxes
array
required
Global meta boxes array
Example
add_filter( 'web_stories_editor_meta_boxes', function( $meta_boxes ) {
    // Remove specific meta boxes from story editor
    unset( $meta_boxes['web-story']['side']['default']['my-meta-box'] );
    
    return $meta_boxes;
} );
Location: includes/Admin/Meta_Boxes.php:160
Filters the settings passed to the stories dashboard.
$settings
array
required
Array of dashboard settings
Example
add_filter( 'web_stories_dashboard_settings', function( $settings ) {
    // Customize dashboard settings
    $settings['customDashboardOption'] = true;
    $settings['features']['beta'] = current_user_can( 'manage_options' );
    
    return $settings;
} );
Location: includes/Admin/Dashboard.php:247
Filters the REST API paths to preload in the dashboard.
$preload_paths
array
required
Array of REST API endpoint paths
Example
add_filter( 'web_stories_dashboard_preload_paths', function( $preload_paths ) {
    // Preload additional data in dashboard
    $preload_paths[] = '/web-stories/v1/custom-data';
    
    return $preload_paths;
} );
Location: includes/Admin/Dashboard.php:404

Analytics & Ads

Filters the Google Analytics configuration for stories.
$config
array
required
Analytics configuration array
Example
add_filter( 'web_stories_analytics_configuration', function( $config ) {
    // Add custom analytics events
    $config['triggers']['customEvent'] = [
        'on' => 'story-page-visible',
        'request' => 'event',
        'vars' => [
            'event_name' => 'custom_tracking',
            'event_category' => 'web_stories',
        ],
    ];
    
    return $config;
} );
Location: includes/Analytics.php:234
Filters the Google Ad Manager configuration.
$configuration
array
required
Ad Manager configuration
$slot
string
Ad slot identifier
Example
add_filter( 'web_stories_ad_manager_configuration', function( $config, $slot ) {
    // Customize ad configuration
    $config['targeting'] = [
        'category' => 'web-stories',
    ];
    
    return $config;
}, 10, 2 );
Location: includes/Ad_Manager.php:106
Filters the Mgid ad widget configuration.
$configuration
array
required
Mgid configuration
$widget
string
Widget identifier
Example
add_filter( 'web_stories_mgid_configuration', function( $config, $widget ) {
    // Customize Mgid configuration
    return $config;
}, 10, 2 );
Location: includes/Mgid.php:106

Media & Assets

Filters the list of allowed MIME types for story media.
$mime_types
array
required
Array of allowed MIME types
Example
add_filter( 'web_stories_allowed_mime_types', function( $mime_types ) {
    // Add WebP support
    $mime_types['image/webp'] = [
        'image/webp',
    ];
    
    // Add additional video format
    $mime_types['video/webm'] = [
        'video/webm',
    ];
    
    return $mime_types;
} );
Location: includes/Media/Types.php:98
Controls whether auto-generated media attachments are hidden from the media library.
$enabled
bool
default:"true"
Whether to hide auto-generated attachments
$args
array
Query arguments
Example
add_filter( 'web_stories_hide_auto_generated_attachments', function( $enabled, $args ) {
    // Show all attachments for administrators
    if ( current_user_can( 'manage_options' ) ) {
        return false;
    }
    return $enabled;
}, 10, 2 );
Location: includes/Media/Media_Source_Taxonomy.php:370

REST API

Filters the attachment response from the REST API.
$response
WP_REST_Response
required
The response object
$post
WP_Post
Attachment post object
$request
WP_REST_Request
Request object
Example
add_filter( 'web_stories_rest_prepare_attachment', function( $response, $post, $request ) {
    // Add custom data to attachment response
    $data = $response->get_data();
    $data['custom_field'] = get_post_meta( $post->ID, 'custom_field', true );
    $response->set_data( $data );
    
    return $response;
}, 10, 3 );
Location: includes/REST_API/Stories_Media_Controller.php:253
Filters the attachment query arguments in the REST API.
$args
array
required
Query arguments
$request
WP_REST_Request
Request object
Example
add_filter( 'web_stories_rest_attachment_query', function( $args, $request ) {
    // Modify query to only show approved media
    $args['meta_query'][] = [
        'key' => 'media_approved',
        'value' => '1',
    ];
    
    return $args;
}, 10, 2 );
Location: includes/REST_API/Stories_Media_Controller.php:378
Filters the cache TTL for embed data.
$ttl
int
default:"DAY_IN_SECONDS"
Cache time-to-live in seconds
$url
string
The URL being embedded
Example
add_filter( 'web_stories_embed_data_cache_ttl', function( $ttl, $url ) {
    // Cache for 1 hour instead of 1 day
    return HOUR_IN_SECONDS;
}, 10, 2 );
Location: includes/REST_API/Embed_Controller.php:157

AMP & Optimization

Controls whether server-side rendering is enabled for AMP optimization.
$enable
bool
default:"true"
Whether to enable SSR
Example
add_filter( 'web_stories_enable_ssr', '__return_false' );
Location: includes/AMP/Optimization.php:146
Filters the AMP Optimizer configuration.
$configuration
array
required
AMP Optimizer configuration array
Example
add_filter( 'web_stories_amp_optimizer_config', function( $config ) {
    // Customize AMP optimization
    $config['transformations'] = [ 'YOUR_CUSTOM_TRANSFORMATION' ];
    return $config;
} );
Location: includes/AMP/Optimization.php:182
Filters the list of AMP sanitizers.
$sanitizers
array
required
Array of sanitizer class names and configurations
Example
add_filter( 'web_stories_amp_sanitizers', function( $sanitizers ) {
    // Add custom sanitizer
    $sanitizers['My_Custom_Sanitizer'] = [];
    return $sanitizers;
} );
Location: includes/AMP/Sanitization.php:493
Controls whether AMP dev mode is enabled.
$enabled
bool
Whether dev mode is enabled
Example
add_filter( 'web_stories_amp_dev_mode_enabled', function( $enabled ) {
    // Enable dev mode for developers
    return current_user_can( 'manage_options' );
} );
Location: includes/AMP/Sanitization.php:410
Filters whether an AMP validation error should be sanitized.
$sanitized
bool
default:"true"
Whether the error is sanitized
$error
array
The validation error
Example
add_filter( 'web_stories_amp_validation_error_sanitized', function( $sanitized, $error ) {
    // Log validation errors in development
    if ( WP_DEBUG ) {
        error_log( print_r( $error, true ) );
    }
    return $sanitized;
}, 10, 2 );
Location: includes/AMP/Sanitization.php:125
Controls whether HTML decoding is enabled for story content.
$enable
bool
default:"true"
Whether to enable decoding
Example
add_filter( 'web_stories_enable_decoding', '__return_false' );
Location: includes/Decoder.php:52

Blocks & Embeds

Filters the settings for the Web Stories Gutenberg block.
$settings
array
required
Block settings array
Example
add_filter( 'web_stories_block_settings', function( $settings ) {
    // Customize block settings
    $settings['defaultAttributes']['numOfStories'] = 5;
    return $settings;
} );
Location: includes/Block/Web_Stories_Block.php:367
Filters the default attributes for story embeds.
$attrs
array
required
Default embed attributes
Example
add_filter( 'web_stories_embed_default_attributes', function( $attrs ) {
    // Set default embed width
    $attrs['width'] = 600;
    $attrs['height'] = 800;
    return $attrs;
} );
Location: includes/Embed_Base.php:217

Shopping & E-commerce

Filters the list of available shopping vendors.
$vendors
array
required
Array of shopping vendor configurations
Example
add_filter( 'web_stories_shopping_vendors', function( $vendors ) {
    // Add custom shopping vendor
    $vendors['custom_shop'] = [
        'name' => 'My Custom Shop',
        'url' => 'https://shop.example.com',
    ];
    return $vendors;
} );
Location: includes/Shopping/Shopping_Vendors.php:111
Filters the cache TTL for Shopify product data.
$ttl
int
default:"5 * MINUTE_IN_SECONDS"
Cache time-to-live in seconds
Example
add_filter( 'web_stories_shopify_data_cache_ttl', function( $ttl ) {
    return 10 * MINUTE_IN_SECONDS;
} );
Location: includes/Shopping/Shopify_Query.php:328

Action Hooks

Explore action hooks for executing custom code

Custom Post Types

Learn about custom post types in the plugin

Build docs developers (and LLMs) love