This example shows how to set the “_payments_accepted” custom field value to the paymentsAccepted property in the Schema AutoRepair type. Note the leading underscore in the “_payments_accepted” custom field name, which has become an unofficial standard to keep custom field names (and their values) from being shown on the webpage automatically by some themes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
add_filter( 'wpsso_json_data_https_schema_org_autorepair', 'filter_json_data_auto_repair', 10, 2 ); function filter_json_data_auto_repair( $json_data, $mod ) { if ( $mod['is_post'] && $mod['id'] ) { $json_data['paymentsAccepted'] = (string) get_post_meta( $mod['id'], '_payments_accepted', $single = true ); } return $json_data; } |
See the $mod variable documentation for more information on the $mod array and its elements.