Skip to content

Instantly share code, notes, and snippets.

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 iWebbers/6cffe632f1294f682b54d6f49d2ec35b to your computer and use it in GitHub Desktop.
Save iWebbers/6cffe632f1294f682b54d6f49d2ec35b to your computer and use it in GitHub Desktop.
if (is_single()) {
$sd_title = esc_html(get_the_title());
$sd_headline = substr(wp_strip_all_tags(get_the_excerpt()),0,107) . '...';
$sd_image = get_the_post_thumbnail_url();
$sd_permalink = esc_url(get_permalink());
$sd_published = get_the_date('c');
$sd_modified = get_the_modified_date('c');
$sd_author = esc_html(get_the_author());
$sd_organization = get_bloginfo('name');
$sd_modified = get_the_modified_date('c');
echo '
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "' . $sd_permalink .'"
},
"headline": "' . $sd_headline . '",
"image": [
"' . $sd_image . '"
],
"datePublished": "' . $sd_published . '",
"dateModified": "' . $sd_modified . '",
"author": {
"@type": "Person",
"name": "' . $sd_author . '"
},
"publisher": {
"@type": "Organization",
"name": "' . $sd_organization . '",
"logo": {
"@type": "ImageObject",
"url": "your-url-to-the-logo-image"
}
},
"description": "' . $sd_title . '"
}
</script>
';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment