Skip to content

Instantly share code, notes, and snippets.

@felixarntz
Created November 6, 2013 12:24
Show Gist options
  • Save felixarntz/7335240 to your computer and use it in GitHub Desktop.
Save felixarntz/7335240 to your computer and use it in GitHub Desktop.
<?php
function yourtheme_html_schema()
{
$base = 'http://schema.org/';
if( is_page( 5 /* type in the ID of your contact page here, 5 is an example */ ) )
{
$type = 'ContactPage';
}
elseif( is_page( 4 /* type in the ID of your about page here, 5 is an example */ ) )
{
$type = 'AboutPage';
}
elseif( is_singular( array( 'book', 'movie' ) /* add custom post types that describe a single item to this array */ ) )
{
$type = 'ItemPage';
}
elseif( is_author() )
{
$type = 'ProfilePage';
}
elseif( is_search() )
{
$type = 'SearchResultsPage';
}
else
{
$type = 'WebPage';
}
echo 'itemscope="itemscope" itemtype="' . $base . $type . '"';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment