Home » Hooks » Schema.org: After Product Variants

Schema.org: After Product Variants

OBS Hilfecenter
Inhalt

Der obs_structured_data_after_product_variants Filter filtert die Ausgabe der Schema.org Daten für ein Produkt auf einer Produktseite.

Alle eventuell vorhandenen Varianten des Produkts werden als Liste ausgeliefert.

Die Schema.org Daten werden als JSON-LD im Header ausgeliefert.

Dieser Filter läuft, nachdem die HTML-Representation erstellt wurde und bevor sie ausgegeben wird.

Beispiel-Anwendung über functions.php in Child-Theme

add_filter( 'obs_structured_data_after_product_variants', 'custom_structured_data_after_product_variants', 10, 2 );
function custom_structured_data_after_product_variants( $structured_data_after_product_variants, $class) {
    // TODO: change the $structured_data_after_product_variants.
    return $structured_data_after_product_variants;
}

Anleitung zur Integration von Hooks

Eine Integration im Code

/**
 * Filter the structured data of a product after the default setting up. An array of schema.org-Products
 *
 * @param array  $structured_data_product An array of products (all variants of the product) in structured data format.
 * @param string $class                   Name of the class: Oneboxshop_Product_Page.
 *
 * @since 1.12
 */
$structured_data_product = apply_filters_ref_array(
	'obs_structured_data_after_product_variants',
	array(
		$structured_data_product,
		$class,
	)
);

Hilfecenter: