Skip to content

Instantly share code, notes, and snippets.

@rickrduncan
Last active December 25, 2015 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickrduncan/6963824 to your computer and use it in GitHub Desktop.
Save rickrduncan/6963824 to your computer and use it in GitHub Desktop.
Genesis 2.0 - Filter schema attributes for body element.
<?php
//* Do NOT include the opening php tag
//* Change microdata schema when on the About or Contact page.
//* http://schema.org/docs/documents.html
//* genesis/lib/functions/markup.php
add_filter( 'genesis_attr_body', 'rvam_body_schema' );
function rvam_body_schema( $attributes ){
//* Use AboutPage schema on our about page
if( is_page( array( 'about', 1727 ) ) ) {
$attributes['itemtype'] = 'http://schema.org/AboutPage';
}
//* Use ContactPage schema on our contact page
if( is_page( 'contact' ) ) {
$attributes['itemtype'] = 'http://schema.org/ContactPage';
}
return $attributes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment