Modifying Schema Output
-
Hi first would like to know will the hooks work with the free version?
We are looking to add reviewedBy to NewsArticle schema
Doing something like this not working
function modify_article_schema_output( $schema ) { // Get the post ID $post_id = get_the_ID(); // Get 'article_reviewed_by' field value $reviewer = get_field('article_reviewed_by', $post_id); // Check if 'article_reviewed_by' field is not empty if ( !empty($reviewer) ) { // Get the reviewer's name and ID $reviewer_name = $reviewer['display_name']; $reviewer_id = $reviewer['ID']; // Build the URL $url = site_url() . "#/schema/person/" . md5( $reviewer_id ); // Add 'reviewedBy' to the schema $schema['reviewedBy'] = array( array( 'name' => $reviewer_name, '@id' => $url ) ); // Add 'lastReviewed' to the schema $schema['lastReviewed'] = get_the_modified_date( 'Ymd', $post_id ); } return $schema; } // Add the filter add_filter( 'saswp_modify_news_article_schema_output', 'modify_article_schema_output' );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Modifying Schema Output’ is closed to new replies.