Skip to content

Instantly share code, notes, and snippets.

@bkd27
Forked from tlongren/functions.php
Created July 29, 2014 00:56
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 bkd27/5408d247c86fcf335692 to your computer and use it in GitHub Desktop.
Save bkd27/5408d247c86fcf335692 to your computer and use it in GitHub Desktop.
Function for wordpress schema.org
<?php
function html_tag_schema() {
$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 . $type . '"';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment