Skip to content
Reference

Citelayer® Hooks & Filters Reference — WordPress Developer Guide

7 min read


Citelayer® exposes a comprehensive set of WordPress filters that let you customize every output — from structured data schemas to llms.txt content and protocol responses. Each filter follows standard WordPress conventions and receives well-documented parameters.

All filters listed on this page are available since version 0.3.0. For endpoint-level documentation, see the REST API Reference.

Schema Filters

These filters let you modify the JSON-LD structured data that Citelayer® injects into your pages. Use them to add properties, change types, or extend the schema graph. For an overview of how Citelayer® generates schema markup, see Schema & Structured Data.

citelayer_organization_schema

Filters the Organization schema array before Citelayer® outputs it as JSON-LD. Use this filter to add social profiles, contact information, or change the organization type.

Parameters

Parameter Type Description
$schema array Organization schema data including @type, name, url, and all configured properties.

Source: Schema.php line 312
Since: 0.3.0

add_filter( 'citelayer_organization_schema', 'my_customize_organization_schema' );

function my_customize_organization_schema( $schema ) {
	// Add social profile links.
	$schema['sameAs'] = array(
		'https://twitter.com/yourhandle',
		'https://www.linkedin.com/company/yourcompany',
		'https://github.com/yourorg',
	);

	// Add a contact point.
	$schema['contactPoint'] = array(
		'@type'       => 'ContactPoint',
		'telephone'   => '+1-800-555-0199',
		'contactType' => 'customer service',
		'areaServed'  => 'US',
	);

	// Change to a more specific organization type.
	$schema['@type'] = 'Corporation';

	return $schema;
}

citelayer_website_schema

Filters the WebSite schema array before output. Use this filter to customize the search action, add alternative names, or modify site-level structured data.

Parameters

Parameter Type Description
$schema array WebSite schema data including @type, url, name, publisher, and potentialAction.

Source: Schema.php line 364
Since: 0.3.0

add_filter( 'citelayer_website_schema', 'my_customize_website_schema' );

function my_customize_website_schema( $schema ) {
	// Add an alternative site name.
	$schema['alternateName'] = 'YS';

	// Add a custom SearchAction targeting a specific search page.
	$schema['potentialAction'] = array(
		'@type'       => 'SearchAction',
		'target'      => array(
			'@type'       => 'EntryPoint',
			'urlTemplate' => home_url( '/search/{search_term_string}' ),
		),
		'query-input' => 'required name=search_term_string',
	);

	return $schema;
}

citelayer_article_schema

Filters the Article or BlogPosting schema for individual posts. This filter receives both the schema array and the WP_Post object, so you can conditionally modify schema based on post type, category, or custom fields.

Parameters

Parameter Type Description
$schema array Article/BlogPosting schema data for the current post.
$post WP_Post The WordPress post object being rendered.

Source: Schema.php line 434
Since: 0.3.0

add_filter( 'citelayer_article_schema', 'my_customize_article_schema', 10, 2 );

function my_customize_article_schema( $schema, $post ) {
	// Use TechArticle for posts in the "tutorials" category.
	if ( has_category( 'tutorials', $post ) ) {
		$schema['@type'] = 'TechArticle';
		$schema['proficiencyLevel'] = 'Beginner';
	}

	// Add a custom citation from a meta field.
	$citation = get_post_meta( $post->ID, '_article_citation', true );
	if ( $citation ) {
		$schema['citation'] = $citation;
	}

	// Add word count.
	$schema['wordCount'] = str_word_count( wp_strip_all_tags( $post->post_content ) );

	return $schema;
}

Content & Protocol Filters

These filters let you customize the content Citelayer® generates for AI-facing protocols. For feature overviews, see llms.txt, WebMCP, and UCP.

citelayer_llmstxt_content

Filters the llms.txt content before Citelayer® outputs it. Important: this filter receives an array of lines (strings), not a single string. Each element represents one line in the final output.

Parameters

Parameter Type Description
$content array Array of content lines (strings). Each element becomes one line in the output.

Source: LLMS_TXT.php line 262
Since: 0.3.0

add_filter( 'citelayer_llmstxt_content', 'my_customize_llmstxt' );

function my_customize_llmstxt( $content ) {
	// Add a custom section at the end.
	$content[] = '';
	$content[] = '## API Documentation';
	$content[] = '- [REST API Reference](https://yoursite.com/docs/api/)';
	$content[] = '- [Webhooks Guide](https://yoursite.com/docs/webhooks/)';

	// Remove lines containing a specific URL.
	$content = array_filter( $content, function ( $line ) {
		return strpos( $line, '/internal-draft/' ) === false;
	} );

	// Re-index the array after filtering.
	$content = array_values( $content );

	return $content;
}

citelayer_webmcp_context

Filters the full WebMCP context data before Citelayer® serves it at /.well-known/mcp/context.json. Use this filter to add custom capabilities, modify the endpoint list, or inject metadata. See WebMCP for protocol details.

Parameters

Parameter Type Description
$context array Full WebMCP context data including site info, capabilities, and endpoints.

Source: WebMCP.php line 145
Since: 0.3.0

add_filter( 'citelayer_webmcp_context', 'my_customize_webmcp_context' );

function my_customize_webmcp_context( $context ) {
	// Add a custom capability.
	if ( isset( $context['capabilities'] ) ) {
		$context['capabilities']['custom_search'] = true;
	}

	// Add custom metadata.
	$context['metadata'] = array(
		'support_email' => 'dev@yoursite.com',
		'api_version'   => '2.1',
	);

	return $context;
}

citelayer_ucp_discovery_response

Filters the UCP (Unified Commerce Protocol) discovery response before Citelayer® returns it. Use this filter to add custom capabilities or modify shop information. See UCP Commerce Protocol for protocol details.

Parameters

Parameter Type Description
$response_data array UCP discovery response including protocol, version, shop, and capabilities.

Source: UCP_Discovery.php line 115
Since: 0.3.0

add_filter( 'citelayer_ucp_discovery_response', 'my_customize_ucp_discovery' );

function my_customize_ucp_discovery( $response_data ) {
	// Add custom shop metadata.
	$response_data['shop']['industry']       = 'Electronics';
	$response_data['shop']['currency']       = 'EUR';
	$response_data['shop']['shipping_zones'] = array( 'EU', 'US', 'UK' );

	// Override capabilities if your integration supports them.
	$response_data['capabilities']['product_browsing'] = true;

	return $response_data;
}

Compatibility Filters

Citelayer® automatically detects third-party SEO plugins and manages feature conflicts. These filters let you override detection results and conflict resolution. See SEO Plugin Compatibility for background.

citelayer_detected_seo_plugins

Filters the array of detected SEO plugin slugs. Use this filter to force-add a custom or private SEO plugin that Citelayer® doesn’t detect automatically, or to exclude a plugin from detection results.

Parameters

Parameter Type Description
$plugins array Array of detected plugin slugs (e.g., array( 'yoast-seo', 'rank-math' )).

Source: Compatibility.php line 380
Since: 0.3.0

add_filter( 'citelayer_detected_seo_plugins', 'my_customize_seo_detection' );

function my_customize_seo_detection( $plugins ) {
	// Force-add a custom SEO plugin so Citelayer® recognizes it.
	$plugins[] = 'my-custom-seo-plugin';

	// Exclude a plugin from detection (treat it as not installed).
	$plugins = array_diff( $plugins, array( 'all-in-one-seo-pack' ) );

	return array_values( $plugins );
}

citelayer_feature_conflicts

Overrides conflict detection for specific feature and plugin combinations. Citelayer® checks whether a feature (like schema output) conflicts with an active SEO plugin. Use this filter to force a feature on or off regardless of the default detection logic.

Parameters

Parameter Type Description
$conflicts bool true if Citelayer® detected a conflict, false otherwise.
$feature string The feature being checked (e.g., 'schema', 'meta_tags').
$plugin string The plugin slug that triggered the conflict check.

Source: Compatibility.php line 601
Since: 0.3.0

add_filter( 'citelayer_feature_conflicts', 'my_override_feature_conflicts', 10, 3 );

function my_override_feature_conflicts( $conflicts, $feature, $plugin ) {
	// Allow Citelayer® schema output even when Yoast SEO is active.
	if ( 'schema' === $feature && 'yoast-seo' === $plugin ) {
		return false;
	}

	// Force-disable a feature for a specific plugin.
	if ( 'meta_tags' === $feature && 'rank-math' === $plugin ) {
		return true;
	}

	return $conflicts;
}

Best Practices

  • Always return the filtered value. Every filter callback must return the modified (or unmodified) data. Forgetting the return statement silently breaks output.
  • Use the correct number of accepted arguments. Filters like citelayer_article_schema and citelayer_feature_conflicts pass multiple parameters. Declare the argument count in add_filter() (e.g., 10, 2 or 10, 3).
  • Place filter code in your theme’s functions.php or a custom plugin. Avoid editing Citelayer® files directly — updates will overwrite your changes.
  • Test with WP_DEBUG enabled. Schema output errors appear in the debug log and help you catch malformed data early.
  • Validate schema changes. After modifying schema filters, test your pages with Google’s Schema Validator to ensure valid JSON-LD.

citelayer_bot_analytics_cleanup_days

Controls bot visit retention. $days (int), default 90.

add_filter( 'citelayer_bot_analytics_cleanup_days', function( $days ) {
    return 180;
} );

citelayer_product_feed_max_items

Max products in XML feed. $max (int), default 1000.

add_filter( 'citelayer_product_feed_max_items', function( $max ) {
    return 2500;
} );