Last active
November 18, 2018 01:33
-
-
Save jrstaatsiii/211479fb332449efbb4020c4deef8acb to your computer and use it in GitHub Desktop.
Schema
This file contains hidden or 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 schema_builder( $context ) { | |
$html = '<script type= "application/ld+json">'; | |
$html .= '{'; | |
$html .= '"@context": "http://schema.org",'; | |
$html .= '"@type": "Organization",'; | |
$html .= '"@name": "' . get_blog_info('name') . ',"; | |
$html .= '"@url": "' . get_blog_info('url') . ',"; | |
if ( $has_brand_logo ) { | |
$html .= '"@logo":'; | |
$html .= '{'; | |
$html .= '"@type": "ImageObject",'; | |
$html .= '"@url": ' . $brand_logo_url . '",'; | |
$html .= '},'; | |
} | |
if ( $has_social_networks ) { | |
$html .= '"sameAs": ['; | |
if ( $facebook ) { | |
$html .= '"' . $facebook . '",'; | |
} | |
if ( $twitter ) { | |
$html .= '"' . $twitter . '",'; | |
} | |
if ( $google_plus ) { | |
$html .= '"' . $google_plus . '",'; | |
} | |
// ... | |
$html .= ']'; | |
} | |
if ( is_singular('post') ) { | |
// $type = NewsArticle | |
$html .= '"@type" : ' . $type . '",'; | |
// loop through all approved cpts | |
} elseif (is_singular($cpt) ) { | |
} elseif (is_page() ) { | |
} elseif ( is_category || is_tag() { | |
} elseif ( is_archive() { | |
} | |
$html .= '"@headline" : "' . get_the_title() . '",'; | |
$html .= '"@datePublished": "' . get_the_date() '",'; | |
// ... | |
$html .= '}'; | |
$html .= '</script>'; | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment