Add JSON-LD Schema Markup without Plugins

In this article i teach you, How you can make schema markup dynamic code for WordPress website. And you want to add schema markup without using any plugins so follow given steps and make schema markup for your WordPress Website.

How to Create JSON-LD Schema Markup

  • Open given code on any php code reader or paste on WordPress’s theme.
  • Then write/change schema type name for your website.

Code

<script type="application/ld+json">
{
"@context":"https://schema.org",
"@graph":[
{
"@type":"Article",
"@id":"<?php the_permalink(); echo '/#article';?>",
"isPartOf":
{
"@id":"<?php the_permalink(); ?>"
},
"headline":"<?php the_title(); ?>",
"datePublished": "<?php echo get_the_date( 'Y-m-d\TH:i:s'); ?>",
"dateModified": "<?php the_modified_date('Y-m-d\TH:i:s'); ?>",
"mainEntityOfPage":
{
"@id":"<?php the_permalink(); ?>"
},
"publisher":
{"@id":"<?php the_permalink(); echo '/#organization';?>"},
"inLanguage":"en-US"},
{
"@type":"WebPage",
"@id":"<?php the_permalink(); ?>",
"url":"<?php the_permalink(); ?>",
"name":"<?php the_title(); ?>",
"isPartOf":{"@id":"<?php echo get_site_url(); echo '/#website';?>"},
"datePublished": "<?php echo get_the_date( 'Y-m-d\TH:i:s'); ?>",
"dateModified": "<?php the_modified_date('Y-m-d\TH:i:s'); ?>",
"breadcrumb":{"@id":"<?php the_permalink(); echo '/#breadcrumb';?>"},
"inLanguage":"en-US",
"potentialAction":[
{"@type":"ReadAction",
"target":["<?php the_permalink(); ?>"]}]},
{"@type":"BreadcrumbList",
"@id":"<?php the_permalink(); echo '/#breadcrumb';?>",
"itemListElement":[{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "<?php echo get_site_url(); echo '/';?>"
},
{
"@type": "ListItem",
"position": 2,
"name": "<?php
$cat = get_the_category();
$parentCatName = get_cat_name($cat[0]->parent);
if ($cat[0]->category_parent){
echo $parentCatName;
}
else {
echo $cat[0]->cat_name;}
?>",
"item": "<?php
$cat = get_the_category();
$parentCatLink = get_category_link($cat[0]->parent);
$categoryLink = get_category_link($cat[0]->cat_ID );
if ($cat[0]->category_parent){
echo $parentCatLink;
}
else {
echo $categoryLink;
}
?>"},
{
"@type": "ListItem",
"position": 3,
"name": "<?php the_title(); ?>"
}]},
{
"@type":"WebSite",
"@id":"<?php echo get_site_url(); echo '/#website';?>",
"url":"<?php echo get_site_url(); ?>",
"name":"<?php bloginfo('name'); ?>",
"publisher":{"@id":"<?php echo get_site_url(); echo '/#organization';?>"},
"potentialAction":[
{"@type":"SearchAction",
"target":{"@type":"EntryPoint",
"urlTemplate":"<?php echo get_site_url(); echo '/?s={search_term_string}'; ?>"},
"query-input":"required name=search_term_string"}],
"inLanguage":"en-US"},
{"@type":"Organization",
"@id":"<?php echo get_site_url(); echo '/#organization';?>",
"name":"<?php bloginfo('name'); ?>",
"url":"<?php echo get_site_url(); ?>",
"logo":{
"@type":"ImageObject",
"inLanguage":"en-US",
"@id":"<?php echo get_site_url(); echo '/#/schema/logo/image/';?>",
"url":"<?php echo get_site_icon_url() ?>",
"contentUrl":"<?php echo get_site_icon_url() ?>",
"caption":"<?php bloginfo('name'); ?>"
},
"image":{"@id":"<?php echo get_site_url(); echo '/#/schema/logo/image/';?>"},
"sameAs":["https://www.facebook.com/TheKroyaard"]}]
}
</script>

Change green colored text to Blogposting, News, Music or any schema type name.

  • Then SAVE on single.php’s header section.