SEO Microdata on EVERY post & page the easy way :: 2018-06-26 15:36:18

Google structured data markup Javascript ld-json

Javascript ld-json

 

Microdata

is a WHATWG HTML specification used to nest metadata within existing content on web pages. Search engines, web crawlers, and browsers can extract and process Microdata from a web page and use it to provide a richer browsing experience for users.

put this in the header.php (oviously adjust for your site)

<?php

global $post;

if(!empty($post)):

$up_array = wp_upload_dir();
$postid = $post->ID;
$article_url=get_permalink($postid);
$article_publish_date=$post->post_date;
$article_modify_date=$post->post_modified;
$article_author=get_the_author_meta(“display_name”,$post->post_author);
$article_title=$post->post_title;
$article_image=$up_array[“baseurl”].”/2018/01/speedwayfightclub-fist.png”;
?>

make sure you use type equals application linked data – json in the tag as the script “type” attribute

&amp;lt;script type="application/ld+json"&amp;gt;

do not change the schema context ‘”@context”: “http://schema.org”, “@type”: “NewsArticle”, “mainEntityOfPage”: { “@type”: “WebPage”, “@id”: “YOUR PAGE/POST TITLE HERE”‘

// this one goes in the header,
// this is to identify the organization…
{
"@context": "http://schema.org",
"@type": "Organization",
"name": "Speedway Fight Club",
"url": "http://SpeedwayFightClub.com/",
"logo": "&amp;lt;?php echo $article_image; ?&amp;gt;",
"foundingDate": "",
"founders":
[
{
"@type": "Person",
"name": "William Holt"
},
{
"@type": "Person",
"name": ""
}
],
"address":
{
"@type": "PostalAddress",
"streetAddress": "795 Congress St.",
"addressLocality": "Portland, ME",
"postalCode": "04102",
"addressCountry": "US"
},
"contactPoint":
{
"@type": "ContactPoint",
"contactType": "Owner",
"telephone": "[12063179990]",
"email": "bill@SpeedwayFightClub.com"
},
"sameAs":
[
"https://www.facebook.com/SpeedwayFightClub.com/"
"https://twitter.com/SpeedwayFightClub",
"https://plus.google.com/SpeedwayFightClub.com"
]
}
// this one goes in the header also,
// the data changes dynamically with each post/page
// if it is the home/front page (we may need is_home, or is_front_page)
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"mainEntityOfPage":
{
"@type": "WebPage",
"@id": "&amp;lt;?php if(!is_home()):echo $article_url;else:echo "speedwayfightclub.com"; endif; ?&amp;gt;"
},
"headline": "&amp;lt;?php if(!is_home()):echo $article_title;else:echo "home of the speedwayfightclub"; endif; ?&amp;gt;",
"image":
[
"&amp;lt;?php echo $article_image; ?&amp;gt;"
],
"datePublished": "&amp;lt;?php echo $article_publish_date; ?&amp;gt;",
"dateModified": "&amp;lt;?php echo $article_modify_date; ?&amp;gt;",
"author":
{
"@type": "person",
"name": "&amp;lt;?php echo $article_author; ?&amp;gt;"
},
"publisher":
{
"@type": "Organization",
"name": "Speedway Fight Club",
"logo":
{
"@type": "ImageObject",
"url": "&amp;lt;?php echo $article_image; ?&amp;gt;"
}
},
"description": "&amp;lt;?php if(!is_home()):echo $article_title;else: echo "Web Development &amp;amp; Programming"; endif; ?&amp;gt;"
}

now go back to google and let in the bots! (re-crawl your site) with your new shiny microdata available to google… Have Google “Crawl” your site now but go here first: structured data testing tool and make sure your markup is correct validate…

«