跳转到主要内容

acf/schema/schema_types

Filter available Schema.org types in admin dropdowns.

Description

This filter allows you to modify the list of Schema.org types available in the admin UI when configuring post types and blocks. Types are organized in groups for easier navigation.

Changelog

  • Added in version 6.8.0

Parameters

apply_filters( 'acf/schema/schema_types', $types );
  • $types (array) Hierarchical array of types grouped by category

Return

(array) The modified types array.

Example

This example adds custom Schema.org types.

/**
 * Add custom Schema.org types.
 *
 * @param array $types Grouped array of Schema.org types.
 * @return array Modified types array.
 */
function my_acf_schema_add_types( $types ) {
    // Add custom types group
    $types['Custom Types'] = array(
        'SoftwareApplication' => 'SoftwareApplication',
        'MobileApplication'   => 'MobileApplication',
        'WebApplication'      => 'WebApplication',
    );

    return $types;
}
add_filter( 'acf/schema/schema_types', 'my_acf_schema_add_types' );

This example removes types not needed for your site.

/**
 * Remove unused Schema.org types.
 *
 * @param array $types Grouped array of Schema.org types.
 * @return array Modified types array.
 */
function my_acf_schema_remove_types( $types ) {
    // Remove types we don't use
    if ( isset( $types['Common Types'] ) ) {
        unset( $types['Common Types']['Recipe'] );
        unset( $types['Common Types']['Event'] );
    }

    return $types;
}
add_filter( 'acf/schema/schema_types', 'my_acf_schema_remove_types' );