1. Home
  2. Docs
  3. For Developer
  4. Add custom Schema values

Add custom Schema values

There are filters you can use to add custom schema markup values.

1 – citybook_schema_listing_metas

You can add your own value string ( {{custom_value}} ) to filter $values variable then return modified values. The $values variable is an array with key is listing meta tag, value is string.

add_filter( 'citybook_schema_listing_metas', function($values){
    $values['{{custom_value}}'] = 'Your custom value';
    return $values;
} );

Then the value will display on listing values dropdown for selecting

2 – citybook_schema_value

This filter receive three variable

  1. value – schema value. Ex: {{custom_value}} if your new custom value is selected
  2. listing_id – listing post id to get data from
  3. name – schema markup name. Ex: openingHours for opening hours field, or aggregateRating/@type for aggregate rating then @type field.
add_filter( 'citybook_schema_value', function($value, $id, $name){
    if($value == '{{custom_value}}' && $name == 'telephone' ){
        $value = get_post_meta( $id, '_cth_contact_infos_phone', true );
    return $value;
}, 10, 3 );

Watch how to add schema markup to your listings at this doc

Was this article helpful to you? Yes No

How can we help?