wpbdp_field_schema_org

Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

This hook can be used to include or edit Schema.org items for each form field; here's an example to illustrate field filtering.

Usage

add_action( 'wpbdp_field_schema_org', 'wpbdp_schema_org_fields' );

Parameters

  • $schema (array)
  • $field (object)
  • $post_id (string)

Examples

Field filtering

This example will edit some Schema.org items

add_filter('wpbdp_field_schema_org', 'wpbdp_schema_org_fields', 10, 3 );
function wpbdp_schema_org_fields( $schema, $field, $post_id ) {
    // Using field ID
    if ( 10 == $field->get_id() ) { // Replace the value 10 with the value of the field if you need
        $schema['legalName'] = $field->plain_value( $post_id );
    }

    // Using field Shortname
    if ( 'business_fax' === $field->get_shortname() ) { // Replace the business_fax value with the value of the Shortname you need
        $schema['faxNumber'] = $field->plain_value( $post_id );
    }


    return $schema;
}

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support