Created
August 11, 2018 05:56
-
-
Save iWebbers/6cffe632f1294f682b54d6f49d2ec35b to your computer and use it in GitHub Desktop.
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
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