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