waynedunkley
5/9/2016 - 1:10 AM

Wordpress Article page with Structured Data Schema Meta Mark Up

Wordpress Article page with Structured Data Schema Meta Mark Up

<article itemscope itemtype="http://schema.org/Article">
  <?php
    $articleData['publishedBy'] = 'Fitness first';
    $articleData['publisherLogo'] = get_stylesheet_directory_uri() . '/images/get-there-logo-400.png';
  ?>

  <!-- META DATA -->
  <meta itemscope itemprop="mainEntityOfPage"  itemType="https://schema.org/WebPage" itemid="<?php the_permalink();?>"/>
  <meta itemprop="author" content="<?php the_author();?>"/>
  <?php $publishDate = new DateTime( get_the_date() ); ?>
  <meta itemprop="datePublished" content="<?php echo $publishDate->format('Y-m-d H:i');?>"/>
  <?php $modifiedDate = new DateTime( get_the_modified_date() ); ?>
  <meta itemprop="dateModified" content="<?php echo $modifiedDate->format('Y-m-d H:i');?>"/>
  <div itemprop="publisher" itemscope itemtype="https://schema.org/Organization">
    <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
      <?php
        $logo_url = $articleData['publisherLogo'];
        $logo_meta = getimagesize($logo_url);
      ?>
      <meta itemprop="url" content="<?php echo $logo_url; ?>">
      <meta itemprop="width" content="<?php echo $logo_meta[0];?>">
      <meta itemprop="height" content="<?php echo $logo_meta[1];?>">
    </div>
    <meta itemprop="name" content="<?php echo $articleData['publishedBy'];?>"/>
  </div>
  <!-- end of meta data -->

  <!-- FEATURED IMAGE -->
  <div class="feature-image">
    <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
      <?php the_post_thumbnail(); ?>
      <?php
        if ( has_post_thumbnail() ) {
          $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
          if ( $post_thumbnail_id ) {
            $image_details = wp_get_attachment_image_src( $post_thumbnail_id, 'post-thumbnail' );
          }
        }
      ?>
      <meta itemprop="url" content="<?php echo $image_details[0];?>">
      <meta itemprop="width" content="<?php echo $image_details[1];?>">
      <meta itemprop="height" content="<?php echo $image_details[2];?>">
    </div>
  </div>
  <!-- end of featured image -->

  <!-- ARTICLE TITLE -->
  <h1 class="entry-title" itemscope itemprop="headline"><?php single_post_title(); ?></h1>
  <!-- end of article title -->

  <!-- ARTICLE BODY -->
  <div itemscope itemprop="articleBody">
    <?php the_content(); ?>
  </div>
  <!-- end of article body -->

</article>