Skip to content

Developer Reference

Every schema block passes through a filter before it's written to the page, so you can add, change, or remove properties without touching the extension.

Each filter receives the assembled array and must return an array. Returning an empty array suppresses that block.

dms_seo_schema_vehicle_listing_schema

The Vehicle/Product block for a single listing. Receives the schema array and the Listing object, so any listing data can be pulled in.

add_filter( 'dms_seo_schema_vehicle_listing_schema', function ( array $schema, DMS\Listing $listing ): array {
  $mileage = $listing->get_term( 42 );

  if ( ! empty( $mileage ) ) {
    $schema['mileageFromOdometer'] = [
      '@type'    => 'QuantitativeValue',
      'value'    => $mileage,
      'unitCode' => 'SMI',
    ];
  }

  return $schema;
}, 10, 2 );

This filter also runs for each listing inside the listings scroller, so an addition here appears in both places.

dms_seo_schema_local_business_schema

The LocalBusiness block, including its departments.

add_filter( 'dms_seo_schema_local_business_schema', function ( array $schema ): array {
  $schema['priceRange'] = '$$';

  return $schema;
} );

dms_seo_schema_organization_schema

The Organization block. Useful for filling in properties the settings screen doesn't cover:

add_filter( 'dms_seo_schema_organization_schema', function ( array $schema ): array {
  $schema['name'] = get_bloginfo( 'name' );
  $schema['logo'] = 'https://example.com/logo.png';

  return $schema;
} );

dms_seo_schema_video_schema

The VideoObject block on listings with a video.

add_filter( 'dms_seo_schema_video_schema', function ( array $schema ): array {
  $schema['duration'] = 'PT2M30S';

  return $schema;
} );

Output details

Worth knowing when extending:

  • All four blocks are written on wp_head at priority 1, so they appear early in the document.
  • Output is JSON-LD in a <script type="application/ld+json"> tag, pretty-printed with unescaped slashes.
  • Empty values are omitted as the array is built, so a filter receives only the keys that had data.
  • The scroller's ItemList wraps each listing's schema in a ListItem with a position, and is emitted where the scroller template renders rather than in the head.

Suppressing a block

If another SEO plugin already emits Organization or LocalBusiness data, two copies can conflict. Return an empty array to drop one:

add_filter( 'dms_seo_schema_organization_schema', '__return_empty_array' );