Fired when the framework is ready to register providers.
Parameters:
$app(App) - The main App instance
Usage:
add_action('wp_schema_framework_register_providers', function($app) {
$app->get_registry()->register('custom', new CustomProvider());
});Fired when the framework is fully initialized and ready.
Parameters:
$app(App) - The main App instance
Usage:
add_action('wp_schema_framework_ready', function($app) {
// Framework is ready, do custom initialization
});Fired before schema is output to the page.
Parameters:
$context(string) - Current page context
Usage:
add_action('wp_schema_framework_before_output', function($context) {
// Perform actions before schema output
});Fired after schema has been output to the page.
Parameters:
$context(string) - Current page context$graph(SchemaGraph) - The graph that was output
Usage:
add_action('wp_schema_framework_after_output', function($context, $graph) {
// Perform actions after schema output
}, 10, 2);Enable or disable all schema output.
Parameters:
$enabled(bool) - Whether output is enabled (default: true)
Usage:
// Disable schema on specific pages
add_filter('wp_schema_framework_output_enabled', function($enabled) {
if (is_page('no-schema')) {
return false;
}
return $enabled;
});Override the detected page context.
Parameters:
$context(string) - Detected context ('home', 'singular', 'attachment', 'archive', 'search', '404', 'unknown')
Usage:
add_filter('wp_schema_framework_context', function($context) {
if (is_page('special')) {
return 'custom_context';
}
return $context;
});Modify the complete array of schema pieces before assembly.
Parameters:
$pieces(array) - Array of SchemaPiece objects$context(string) - Current page context
Usage:
add_filter('wp_schema_framework_pieces', function($pieces, $context) {
// Add custom piece
$pieces[] = new SchemaPiece('#custom', 'CustomType');
return $pieces;
}, 10, 2);Modify the final schema graph before output.
Parameters:
$graph(array) - Complete schema graph array
Usage:
add_filter('wp_schema_framework_graph', function($graph) {
// Modify final output
return $graph;
});Modify the final JSON-LD string before it's output.
Parameters:
$json(string) - JSON-LD string$graph_data(array) - Original graph data array
Usage:
add_filter('wp_schema_framework_json_output', function($json, $graph_data) {
// Modify JSON string (e.g., minify, add custom formatting)
return $json;
}, 10, 2);Modify a specific schema piece by type.
Parameters:
$piece(SchemaPiece) - The schema piece$context(string) - Current page context
Available types: article, webpage, organization, person, event, product, etc.
Usage:
add_filter('wp_schema_framework_piece_article', function($piece, $context) {
$piece->set('customProperty', 'value');
return $piece;
}, 10, 2);Modify a specific schema piece by ID.
Parameters:
$piece(SchemaPiece) - The schema piece$context(string) - Current page context
Usage:
// Note: '#' is stripped from IDs when building the hook name, so '#organization' becomes 'organization'
add_filter('wp_schema_framework_piece_id_organization', function($piece, $context) {
$piece->set('telephone', '+1234567890');
return $piece;
}, 10, 2);Modify organization schema data.
Parameters:
$data(array) - Organization schema array$context(string) - Current page context
Override the organization schema type.
Parameters:
$type(string) - Organization type (default: 'Organization')
Usage:
add_filter('wp_schema_framework_organization_type', function($type) {
return 'LocalBusiness';
});Modify website schema data.
Parameters:
$data(array) - Website schema array$context(string) - Current page context
Control whether WebSite schema should be output.
Parameters:
$can_provide(bool) - Whether to output (default: true)$context(string) - Current page context
Modify article schema data.
Parameters:
$data(array) - Article schema array$post_id(int) - Post ID (0 if not applicable)$post(WP_Post|null) - Post object
Modify webpage schema data.
Parameters:
$data(array) - WebPage schema array$post_id(int) - Post ID$post(WP_Post) - Post object
Modify author/person schema data.
Parameters:
$data(array) - Person schema array$author_id(int) - Author user ID$context(string) - Current page context
Modify archive page schema data.
Parameters:
$data(array) - Archive schema array$context(string) - Current page context
Modify search results page schema data.
Parameters:
$data(array) - Search results schema array$context(string) - Current page context$search_query(string) - Search query string
Modify media attachment schema data.
Parameters:
$data(array) - Media schema array$context(string) - Current page context$attachment_id(int) - Attachment ID
Modify specialized page type schema data.
Parameters:
$data(array) - Page type schema array$context(string) - Current page context$schema_type(string) - Detected schema type
Modify product schema data.
Parameters:
$data(array) - Product schema array$context(string) - Current page context$post_id(int) - Product post ID
Determine if a post should be treated as a product.
Parameters:
$is_product(bool) - Whether it's a product$post_id(int) - Post ID$context(string) - Current page context
Provide custom product data.
Parameters:
$data(array|null) - Product data array or null$post_id(int) - Product post ID
Modify WooCommerce product data.
Parameters:
$data(array) - Product data array$product(WC_Product) - WooCommerce product object
Control whether WooCommerce's own schema is considered active.
Parameters:
$active(bool) - Whether WooCommerce schema is active
Modify Easy Digital Downloads product data.
Parameters:
$data(array) - Product data array$download(EDD_Download) - EDD download object
Modify BigCommerce product data.
Parameters:
$data(array) - Product data array$product_id(int) - Product post ID
Modify event schema data.
Parameters:
$data(array) - Event schema array$context(string) - Current page context$post_id(int) - Event post ID
Determine if a post should be treated as an event.
Parameters:
$is_event(bool) - Whether it's an event$post_id(int) - Post ID$context(string) - Current page context
Provide custom event data.
Parameters:
$data(array|null) - Event data array or null$post_id(int) - Event post ID
Modify The Events Calendar event data.
Parameters:
$data(array) - Event data array$event(WP_Post) - Event post object
Control whether The Events Calendar's schema is considered active.
Parameters:
$active(bool) - Whether Tribe Events schema is active
Modify Events Manager event data.
Parameters:
$data(array) - Event data array$em_event(EM_Event) - Events Manager event object
Modify Modern Events Calendar event data.
Parameters:
$data(array) - Event data array$event(array) - MEC event array
Modify Event Organiser event data.
Parameters:
$data(array) - Event data array$event_id(int) - Event post ID
Override the schema type for a specific post.
Parameters:
$schema_type(string) - Schema type to use$post_id(int) - Post ID$post_type(string) - WordPress post type$post(WP_Post) - Post object
Usage:
add_filter('wp_schema_framework_post_type_override', function($type, $post_id, $post_type, $post) {
if (get_post_meta($post_id, 'is_how_to', true)) {
return 'HowTo';
}
return $type;
}, 10, 4);Map WordPress post types to schema types.
Parameters:
$schema_type(string) - Default schema type$post_type(string) - WordPress post type
Provide custom description for posts.
Parameters:
$description(string) - Post description$post_id(int) - Post ID$post(WP_Post) - Post object
Override schema type for the homepage.
Parameters:
$type(string) - Schema type (default: 'WebSite')
Modify homepage schema data.
Parameters:
$data(array) - Homepage schema array
Override schema type for archive items.
Parameters:
$type(string) - Schema type$post_type(string) - WordPress post type
Override schema type for search result items.
Parameters:
$type(string) - Schema type$post_type(string) - WordPress post type
Provide FAQ items for FAQPage schema.
Parameters:
$items(array) - Array of FAQ items$post_id(int) - Post ID
Usage:
add_filter('wp_schema_framework_faq_items', function($items, $post_id) {
return [
['question' => 'Q1?', 'answer' => 'A1'],
['question' => 'Q2?', 'answer' => 'A2'],
];
}, 10, 2);Provide items for CollectionPage schema.
Parameters:
$items(array) - Array of collection items$post_id(int) - Post ID
Provide images for ImageGallery schema.
Parameters:
$items(array) - Array of image URLs$post_id(int) - Post ID
Provide image count for galleries.
Parameters:
$count(int) - Number of images$post_id(int) - Post ID
Modify available schema types for UI.
Parameters:
$types(array) - Array of type definitions
Modify the complete type registry.
Parameters:
$types(array) - All registered schema types
Modify default post type to schema type mappings.
Parameters:
$mappings(array) - Associative array of post_type => schema_type
Modify generic schema data.
Parameters:
$data(array) - Generic schema array$post_id(int) - Post ID (0 if not applicable)$post(WP_Post|null) - Post object
Dynamic filter for any schema type (lowercase).
Parameters:
$data(array) - Schema data array$post_id(int) - Post ID$post(WP_Post|null) - Post object
Example types: howto_data, recipe_data, qapage_data, etc.
- Always return the filtered value - Don't forget to return the modified data
- Check context - Use the context parameter to apply filters selectively
- Use proper priority - Lower numbers run first (default is 10)
- Validate data - Ensure your modifications follow schema.org specifications
- Test thoroughly - Use Google's Rich Results Test to validate output
add_filter('wp_schema_framework_article_data', function($data, $post_id, $post) {
// Add custom property
$data['customProperty'] = get_post_meta($post_id, 'custom_field', true);
return $data;
}, 10, 3);add_filter('wp_schema_framework_output_enabled', function($enabled) {
// Disable on certain pages
if (is_page(['privacy-policy', 'terms'])) {
return false;
}
return $enabled;
});add_filter('wp_schema_framework_post_type_override', function($type, $post_id, $post_type, $post) {
// Use HowTo for posts in 'tutorials' category
if (has_category('tutorials', $post_id)) {
return 'HowTo';
}
return $type;
}, 10, 4);add_filter('wp_schema_framework_organization_data', function($data) {
$data['telephone'] = '+1-555-123-4567';
$data['email'] = 'info@example.com';
$data['contactPoint'] = [
'@type' => 'ContactPoint',
'telephone' => '+1-555-123-4567',
'contactType' => 'customer service'
];
return $data;
});