Created
June 28, 2019 08:16
-
-
Save Matteo182/21400c55326846b42f661d1a8fefd3d7 to your computer and use it in GitHub Desktop.
WordPress Loop in Made theme Google structured Data
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
<?php | |
/** | |
* Post rendering content according to caller of get_template_part. | |
* | |
* @package understrap | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly. | |
} | |
?> | |
<article <?php post_class(); ?> id="post-<?php the_ID(); ?>" role="article" itemprop="hasPart" itemscope="" itemtype="http://schema.org/Article"> | |
<meta itemscope='itemscope' itemprop='mainEntityOfPage' itemType='https://schema.org/WebPage'/> | |
<header class="entry-header"> | |
<?php | |
the_title( | |
sprintf( '<h2 class="entry-title" itemprop="headline"><a href="%s" rel="bookmark" itemprop="url">', esc_url( get_permalink() ) ), | |
'</a></h2>' | |
); | |
?> | |
<?php if ( 'post' == get_post_type() ) : ?> | |
<div class="entry-meta"> | |
<?php understrap_posted_on(); ?> | |
<!-- 2. Post Meta Start --> | |
<p> | |
<!-- 2.1 Published date Start --> | |
Published on <span datetime="<?php echo the_time('c'); ?>" itemprop="datePublished" content="<?php echo the_time('c'); ?>"> | |
<?php the_time('M j, Y'); ?> | |
</span> | |
<!-- 2.1 Published date End --> | |
<!-- 2.2 Author Start --> | |
by <span class="post-author vcard" itemprop="author" itemscope itemtype="https://schema.org/Person"> | |
<span itemprop="name"><?php the_author(); ?></span> | |
</span> | |
<!-- 2.2 Author End --> | |
<!-- 2.3 Category Start --> | |
in <?php the_category(', '); ?> | |
<!-- 2.3 Category End --> | |
</p> | |
<!-- 2. Post Meta End --> | |
</div><!-- .entry-meta --> | |
<?php endif; ?> | |
</header><!-- .entry-header --> | |
<?php echo get_the_post_thumbnail( $post->ID, 'large' ); ?> | |
<!-- 3. Thumbnail Start --> | |
<?php if ( has_post_thumbnail() ) { ?> | |
<span itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> | |
<a href="<?php the_permalink(); ?>" rel="bookmark"> | |
<?php the_post_thumbnail('medium'); ?> | |
</a> | |
<?php | |
$thumb_id = get_post_thumbnail_id(); | |
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'medium', true); | |
$thumb_url = $thumb_url_array[0]; | |
?> | |
<meta itemprop="url" content="<?php echo $thumb_url ?>"> | |
<meta itemprop='width' content='569'/> | |
<meta itemprop='height' content='309'/> | |
</span> | |
<?php } ?> | |
<!-- 3. Thumbnail End --> | |
<div class="entry-content"> | |
<span itemprop="description"> | |
<?php the_excerpt(); ?> | |
</span> | |
<?php | |
wp_link_pages( | |
array( | |
'before' => '<div class="page-links">' . __( 'Pages:', 'understrap' ), | |
'after' => '</div>', | |
) | |
); | |
?> | |
</div><!-- .entry-content --> | |
<footer class="entry-footer"> | |
<?php understrap_entry_footer(); ?> | |
</footer><!-- .entry-footer --> | |
<div class="publisher-img" itemprop="publisher" itemscope itemtype="https://schema.org/Organization"> | |
<div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject"> | |
<img src="site-logo.png" width="396" height="91"/> | |
<meta itemprop="url" content="site-logo.png"> | |
<meta itemprop="width" content="232"> | |
<meta itemprop="height" content="90"> | |
</div> | |
<meta itemprop="name" content="TreeHost Web Solution"> | |
</div> | |
<meta itemprop="dateModified" content="<?php echo the_time('c'); ?>"/> | |
</article><!-- #post-## --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment