Last active
October 11, 2018 15:11
-
-
Save tlongren/9148513 to your computer and use it in GitHub Desktop.
Auto Get Schema Type By Post Type
This file contains 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 characters
<?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