Skip to content

Instantly share code, notes, and snippets.

@ellenmva
Last active August 29, 2015 14:05
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 ellenmva/3ffb796520e1fdd64c09 to your computer and use it in GitHub Desktop.
Save ellenmva/3ffb796520e1fdd64c09 to your computer and use it in GitHub Desktop.
<?php
add_action('the_html_tag' , 'elsue_html_tag_schema');
function elsue_html_tag_schema($type) {
$schema = 'http://schema.org/';
// Is single post
if(is_single()) {
$type = "Article";
}
// Is author page
elseif( is_author() ) {
$type = 'ProfilePage';
}
// Is search results page
elseif( is_search() ) {
$type = 'SearchResultsPage';
}
else {
$type = 'WebPage';
}
echo ' itemscope="itemscope" itemtype="' . $schema . apply_filters( 'elsue_html_tag_schema', $type, $type ) . '"';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment