Last active
August 20, 2021 21:07
-
-
Save daveloodts/46a7e7bb67e3c01e2bcc23de728cfbff to your computer and use it in GitHub Desktop.
schema.org book for WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// define the woocommerce_structured_data_product callback | |
function filter_woocommerce_structured_data_product( $markup, $product ) { | |
$formaat = get_field("boek_formaat"); | |
$authors = get_field("boek_auteurs"); | |
$date = get_the_date('Y m d'); | |
$markup['additionalType'] = "book"; | |
$markup['brand'] = "Ertsberg"; | |
$markup['isbn'] = $product->get_sku(); | |
$markup['author'] = ['@type' => 'Person', 'name' => $authors]; | |
$markup['datePublished'] = $date; | |
$markup['inLanguage'] = "nl-BE"; | |
$markup['copyrightHolder'] = ['@type' => 'Organisation', 'name' => 'Erstberg']; | |
$markup['publisher'] = ['@type' => 'Organisation', 'name' => 'Erstberg']; | |
$markup['bookFormat'] = $formaat; | |
return $markup; | |
}; | |
// add the filter | |
add_filter( 'woocommerce_structured_data_product', 'filter_woocommerce_structured_data_product', 10, 2 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment