CC Schema & Structured Data Hooks Reference

Last updated: 1st May 2026 for CC Schema & Structured Data version 1.0.0

Overview

CC Schema & Structured Data has been designed with extensibility in mind, allowing developers to modify, extend or completely replace schema output using WordPress hooks and filters.

The plugin follows standard WordPress development patterns, meaning:

  • Schema output is filterable before rendering
  • Individual schema blocks can be modified independently
  • JSON-LD output can be extended or overridden
  • Additional schema types can be registered programmatically

This document lists all public hooks and filters intended for developers.

Note: Only hooks with valid extension use cases are documented. Internal hooks and anything related to licensing or restricted functionality are intentionally excluded.


Filter: Modify All Schema Output

cc_schema_output

Filters the final structured data array before it is encoded and output as JSON-LD.

Parameters

  • $schema (array) — Complete schema data for the current page
  • $post_id (int) — Current post ID

Example

add_filter('cc_schema_output', function ($schema, $post_id) {

// Add a custom publisher
$schema['publisher'] = [
'@type' => 'Organization',
'name' => get_bloginfo('name'),
];

return $schema;

}, 10, 2);

Use Cases

  • Add global schema properties
  • Inject organisation or author data
  • Modify schema across all types

Filter: Modify Individual Schema Blocks

cc_schema_block_output

Filters each individual schema block before it is merged into the final output.

Parameters

  • $block (array) — Schema block data
  • $type (string) — Schema type (e.g. faqpage, howto, webpage)
  • $post_id (int) — Current post ID

Example

add_filter('cc_schema_block_output', function ($block, $type, $post_id) {

if ($type === 'webpage') {
$block['inLanguage'] = 'en-GB';
}

return $block;

}, 10, 3);

Use Cases

  • Modify only specific schema types
  • Add or override properties per schema
  • Localise schema output

Filter: Register Custom Schema Types

cc_schema_register_types

Allows developers to register additional schema types.

Parameters

  • $types (array) — Registered schema types

Example

add_filter('cc_schema_register_types', function ($types) {

$types['custom'] = [
'label' => 'Custom Schema',
'class' => \CaterhamComputing\CCSchema\Schema\Custom::class,
];

return $types;

});

Use Cases

  • Add new schema types beyond the default
  • Extend plugin functionality without modifying core
  • Integrate with custom post types

Filter: Modify FAQ Extraction

cc_schema_faq_items

Filters FAQ items extracted from page content.

Parameters

  • $items (array) — Array of FAQ question/answer pairs
  • $post_id (int) — Current post ID

Example

add_filter('cc_schema_faq_items', function ($items, $post_id) {

// Remove empty answers
return array_filter($items, function ($item) {
return !empty($item['answer']);
});

}, 10, 2);

Use Cases

  • Clean extracted FAQ data
  • Modify questions or answers
  • Integrate external FAQ sources

Filter: Modify HowTo Steps

cc_schema_howto_steps

Filters steps used in HowTo schema.

Parameters

  • $steps (array) — Array of steps
  • $post_id (int) — Current post ID

Example

add_filter('cc_schema_howto_steps', function ($steps, $post_id) {

foreach ($steps as &$step) {
$step['text'] = wp_strip_all_tags($step['text']);
}

return $steps;

}, 10, 2);

Use Cases

  • Sanitise step content
  • Add structured enhancements
  • Modify step ordering

Filter: Modify WebPage Schema

cc_schema_webpage

Filters the WebPage schema block specifically.

Parameters

  • $schema (array) — WebPage schema data
  • $post_id (int) — Current post ID

Example

add_filter('cc_schema_webpage', function ($schema, $post_id) {

$schema['about'] = [
'@type' => 'Thing',
'name' => get_the_title($post_id),
];

return $schema;

}, 10, 2);

Use Cases

  • Enhance general page schema
  • Add contextual relationships
  • Improve semantic clarity

Action: Before Schema Output

cc_schema_before_output

Fires immediately before JSON-LD is printed to the page.

Parameters

  • $schema (array) — Final schema data
  • $post_id (int) — Current post ID

Example

add_action('cc_schema_before_output', function ($schema, $post_id) {

// Debug schema output
error_log(print_r($schema, true));

}, 10, 2);

Use Cases

  • Debugging
  • Logging schema output
  • Conditional behaviour before rendering

Action: After Schema Output

cc_schema_after_output

Fires immediately after JSON-LD has been printed.

Parameters

  • $post_id (int) — Current post ID

Example

add_action('cc_schema_after_output', function ($post_id) {

// Trigger additional output if needed

});

Use Cases

  • Trigger additional scripts
  • Extend frontend behaviour

Filter: Control Schema Output Location

cc_schema_output_location

Controls where schema is output (e.g. wp_head or wp_footer).

Parameters

  • $location (string) — Output hook name

Example

add_filter('cc_schema_output_location', function ($location) {
return 'wp_footer';
});

Use Cases

  • Move schema output location
  • Improve compatibility with themes/builders

Filter: Enable or Disable Schema Output

cc_schema_enabled

Determines whether schema should be output on the current page.

Parameters

  • $enabled (bool) — Whether schema output is enabled
  • $post_id (int) — Current post ID

Example

add_filter('cc_schema_enabled', function ($enabled, $post_id) {

if (is_admin()) {
return false;
}

return $enabled;

}, 10, 2);

Use Cases

  • Disable schema conditionally
  • Prevent output on specific pages
  • Integrate with other SEO tools

Filter: Modify Final JSON Encoding

cc_schema_json_flags

Filters the JSON encoding flags used in wp_json_encode.

Parameters

  • $flags (int) — JSON encoding flags

Example

add_filter('cc_schema_json_flags', function ($flags) {
return $flags | JSON_PRETTY_PRINT;
});

Use Cases

  • Enable pretty printing for debugging
  • Adjust encoding behaviour

Best Practices for Developers

1. Always Return Valid Schema

Ensure your modifications comply with Schema.org standards to avoid validation errors.


2. Avoid Removing Required Fields

Removing required properties may prevent rich results from appearing.


3. Use Conditional Logic

Wrap customisations with conditions such as:

if (is_singular('post')) { ... }

4. Test Your Changes

Use structured data testing tools to verify output after applying filters.

Structured data must be correctly formatted JSON-LD to be interpreted by search engines .


Summary

The CC Schema & Structured Data plugin provides a flexible hook system that allows developers to:

  • Modify schema globally or per type
  • Extend schema with custom data
  • Control output behaviour
  • Integrate with themes and other plugins

This ensures the plugin can scale from simple use cases to advanced SEO implementations.