Created
June 21, 2020 22:56
-
-
Save danielpowney/a3eaf712225c9e4cf307558496b890b8 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* 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