Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save danielpowney/a3eaf712225c9e4cf307558496b890b8 to your computer and use it in GitHub Desktop.
Save danielpowney/a3eaf712225c9e4cf307558496b890b8 to your computer and use it in GitHub Desktop.
<?php
/**
* Adds example mainEntityofPage to Product type based on WordPress SEO graph
*/
function mrp_structured_data_type_product_main_entity_example( $schema, $post_id ) {
$structured_data_type = get_post_meta( $post_id, MRP_Multi_Rating::STRUCTURED_DATA_TYPE_POST_META, true );
if ( $structured_data_type === 'Product' ) {
return '
"mainEntityOfPage": "' . get_the_permalink( $post_id ) . '#webpage",
';
}
return '';
}
add_filter( 'mrp_structured_data_type' , 'mrp_structured_data_type_product_main_entity_example', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment