Add Schema Markup Without Plugins in WordPress

Add schema markup without using any plugins, In this article  have microdata method to add schema markup. Follow simple steps on your WordPress’s website.

How to Add Schema Markup

  • Login in Cpannel then open Public_html.
  • Open wp-content then open Theme folder.
  • Find out <body> tag in your theme’s header/index/single file.
  • Then add <div itemscope itemtype=”https://schema.org/Webpage”> this code between <body>.
    {Example : – <body <?php body_class(); ?> itemscope itemtype=”https://schema.org/WebPage”>}
  • Then Open single.php and add itemprop=”mainEntity” itemscope itemtype=”https://schema.org/BlogPosting” between <article>.
    {Example : <article id=”post-<?php the_ID(); ?>” <?php post_class(); ?> itemprop=”mainEntity” itemscope itemtype=”https://schema.org/BlogPosting” itemid>}
  • Then Add itemprop=”headline” in <h1> title tag.
    {Example : <h1 itemprop=”headline”><?php the_title(); ?></h1>}
  • And last code is itemprop=”text” add in the_content(); section.
    {Example : <div itemprop=”text”><?php the_content(); ?></div>}
  • Then SAVE your Single.php file

You have DONE all this code, then check from Schema Validator. Hope you can understand this article.

Full Example : – Single.php

<?php while ( have_posts() ) : the_post();; ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> itemprop="mainEntity" itemscope itemtype="https://schema.org/BlogPosting">
<div class="entry-header">
<h1 itemprop="headline"><?php the_title(); ?></h1>
</div>
<div class="beforetitle">
<span style="display: none;"> <time itemprop="datePublished"><?php echo get_the_date( 'Y-m-d\TH:i:s'); ?></time></span>
<span style="display: none;"> <time itemprop="dateModified"><?php the_modified_date('Y-m-d\TH:i:s'); ?></time> </span>
<span class="postview">
<i class="fa fa-eye"></i>
<?php
echo getPostViews_TheKroyaard(get_the_ID());
?>
</span>
<span class="postsharebutton">
<?php echo "<a href='#share_section'><i class='fa fa-share-alt'></i> Share </a>"; ?>
</span>
</div>
<div itemprop="text">
<?php the_content(); ?>
</div>
</article>
<?php endwhile; // end of the loop. ?>