acf/schema/disable_output

Last updated Mar 31, 2026

Overview

Disable JSON-LD output for a specific data set.

Description

This filter allows you to conditionally prevent JSON-LD output based on the data that would be rendered. Unlike acf/schema/enabled_post_types which controls output at the post type level, this filter runs after data processing and allows you to inspect the actual JSON-LD data before deciding whether to output it.

Changelog

  • Added in version 6.8.0

Parameters

apply_filters( 'acf/schema/disable_output', $disable, $jsonld_data );
  • $disable (bool) Whether to disable output. Default: false
  • $jsonld_data (array) The complete JSON-LD data array that would be output

Return

(bool) Whether to disable JSON-LD output for this data.

Example

This example disables output when no custom fields have been mapped.

/**
 * Disable JSON-LD if only auto-generated data exists.
 *
 * @param bool  $disable     Whether to disable output.
 * @param array $jsonld_data The JSON-LD data array.
 * @return bool Whether to disable output.
 */
function my_acf_schema_require_mapped_fields( $disable, $jsonld_data ) {
    // Check if we only have auto-generated properties
    $auto_properties = array( '@context', '@type', 'name', 'url', 'datePublished', 'dateModified', 'author', 'image' );

    $custom_properties = array_diff( array_keys( $jsonld_data ), $auto_properties );

    if ( empty( $custom_properties ) ) {
        return true; // Disable output
    }

    return $disable;
}
add_filter( 'acf/schema/disable_output', 'my_acf_schema_require_mapped_fields', 10, 2 );

This example disables output for specific schema types.

/**
 * Disable JSON-LD for Person schema type.
 *
 * @param bool  $disable     Whether to disable output.
 * @param array $jsonld_data The JSON-LD data array.
 * @return bool Whether to disable output.
 */
function my_acf_schema_disable_person( $disable, $jsonld_data ) {
    if ( isset( $jsonld_data['@type'] ) && $jsonld_data['@type'] === 'Person' ) {
        return true;
    }
    return $disable;
}
add_filter( 'acf/schema/disable_output', 'my_acf_schema_disable_person', 10, 2 );
Supercharge Your Website With Premium Features Using ACF PRO

Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.

Explore Features View Pricing

PRO Features
ACF Blocks
Options Pages
PRO Fields
Repeater
Flexible Content
Gallery
Clone

Related