Forked from jdevalk/archive-speaking_event.php
Created
June 20, 2013 11:26
Revisions
-
Joost de Valk revised this gist
May 29, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,8 +2,8 @@ // Remove the schema markup from an element function yoast_schema_empty( $attr ) { $attr['itemtype'] = ''; $attr['itemprop'] = ''; $attr['itemscope'] = ''; return $attr; } -
Joost de Valk revised this gist
May 28, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -51,7 +51,7 @@ function yoast_author_schema( $output ) { return str_replace( 'rel="author"', 'itemprop="author"', $output ); } // Add the url itemprop to the URL of the entry function yoast_title_link_schema( $output ) { return str_replace( 'rel="bookmark"', 'rel="bookmark" itemprop="url"', $output ); } -
Joost de Valk revised this gist
May 28, 2013 . 2 changed files with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,7 @@ add_filter( 'genesis_attr_entry', 'yoast_schema_event', 20 ); add_filter( 'genesis_attr_entry-title', 'yoast_itemprop_name', 20 ); add_filter( 'genesis_attr_entry-content', 'yoast_itemprop_description', 20 ); add_filter( 'genesis_post_title_output', 'yoast_title_link_schema', 20 ); /** * We'll use the post info output to add more meta data about the event. This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -50,3 +50,8 @@ function yoast_itemprop_name( $attr ) { function yoast_author_schema( $output ) { return str_replace( 'rel="author"', 'itemprop="author"', $output ); } // Add the url itemprop to the URL of the event function yoast_title_link_schema( $output ) { return str_replace( 'rel="bookmark"', 'rel="bookmark" itemprop="url"', $output ); } -
Joost de Valk revised this gist
May 28, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,9 +13,9 @@ */ function yoast_speaking_post_info( $info ) { global $post; $date = esc_html( get_post_meta( $post->ID, 'date', true ) ); $startdate = '<meta itemprop="startDate" content="' . date('c', strtotime( $date ) ).'">' . $date; $enddate = esc_html( get_post_meta( $post->ID, 'enddate', true ) ); if ( $enddate && $enddate != $date ) $startdate .= ' - <meta itemprop="endDate" content="' . date( 'c', strtotime( $enddate ) ).'">' . $enddate; -
Joost de Valk revised this gist
May 28, 2013 . 1 changed file with 30 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,34 @@ add_filter( 'genesis_attr_entry-title', 'yoast_itemprop_name', 20 ); add_filter( 'genesis_attr_entry-content', 'yoast_itemprop_description', 20 ); /** * We'll use the post info output to add more meta data about the event. * * @param string $info * @return string */ function yoast_speaking_post_info( $info ) { global $post; $date = esc_html( get_post_meta( $post->ID, 'date', true ) ); $startdate = '<meta itemprop="startDate" content="' . date('c', strtotime( $date ) ).'">' . $date; $enddate = esc_html( get_post_meta( $post->ID, 'enddate', true ) ); if ( $enddate && $enddate != $date ) $startdate .= ' - <meta itemprop="endDate" content="' . date( 'c', strtotime( $enddate ) ).'">' . $enddate; $location = esc_html( get_post_meta( $post->ID, 'location', true ) ); if ( $location ) $location = 'at <span itemprop="location" itemscope itemtype="http://schema.org/Place"><span itemprop="name">' . $location . '</span>, '; $city = esc_html( get_post_meta( $post->ID, 'city', true ) ); $country = esc_html( get_post_meta( $post->ID, 'country', true ) ); if ( $location ) $location .= '<span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"><span itemprop="addressLocality">' . $city . '</span>, <span itemprop="addressCountry">' . $country . '</span></span>'; else $location = '<span itemprop="location" itemscope itemtype="http://schema.org/Place"><span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"><span itemprop="addressLocality">' . $city . '</span>, <span itemprop="addressCountry">' . $country . '</span></span></span>'; return "$startdate $location"; } add_filter( 'genesis_post_info' , 'yoast_speaking_post_info' ); genesis(); -
Joost de Valk created this gist
May 28, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ <?php add_filter( 'genesis_attr_content', 'yoast_schema_empty', 20 ); add_filter( 'genesis_attr_entry', 'yoast_schema_event', 20 ); add_filter( 'genesis_attr_entry-title', 'yoast_itemprop_name', 20 ); add_filter( 'genesis_attr_entry-content', 'yoast_itemprop_description', 20 ); genesis(); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ <?php // Remove the schema markup from an element function yoast_schema_empty( $attr ) { $attr['itemtype'] = ''; $attr['itemtype'] = ''; $attr['itemscope'] = ''; return $attr; } // Change the schema type of an element to Product function yoast_schema_product( $attr ) { $attr['itemtype'] = 'http://schema.org/Product'; $attr['itemprop'] = ''; $attr['itemscope'] = 'itemscope'; return $attr; } // Change the schema type of an element to Event function yoast_schema_event( $attr ) { $attr['itemtype'] = 'http://schema.org/Event'; $attr['itemprop'] = ''; $attr['itemscope'] = 'itemscope'; return $attr; } // Change the schema type of an element to Review // Make sure the itemprop is set to review so this can be used in conjunction with Event or Product function yoast_schema_review( $attr ) { $attr['itemtype'] = 'http://schema.org/Review'; $attr['itemprop'] = 'review'; $attr['itemscope'] = 'itemscope'; return $attr; } // Set the itemprop of an element to description function yoast_itemprop_description( $attr ) { $attr['itemprop'] = 'description'; return $attr; } // Set the itemprop of an element to name function yoast_itemprop_name( $attr ) { $attr['itemprop'] = 'name'; return $attr; } // Remove the rel="author" and change it to itemprop="author" as the Structured Data Testing Tool doesn't understand // rel="author" in relation to Schema, even though it should according to the spec. function yoast_author_schema( $output ) { return str_replace( 'rel="author"', 'itemprop="author"', $output ); }