|
<!-- Related Posts --> |
|
<?php |
|
$tags = wp_get_post_tags( get_the_ID() ); |
|
$the_tags = null; |
|
|
|
foreach ( $tags as $tag ) : |
|
|
|
$the_tags[] = $tag->slug; |
|
|
|
endforeach; |
|
|
|
// WP_Query arguments |
|
$args = array ( |
|
'post_type' => array ( 'post' ), |
|
'post_status' => array ( 'publish' ), |
|
'tag_slug__in' => $the_tags, |
|
'post__not_in' => array ( get_the_ID() ) |
|
); |
|
|
|
// The Query |
|
$related = new WP_Query( $args ); |
|
|
|
|
|
if ( $related->have_posts() ) : |
|
|
|
$ctr = 0; |
|
echo '<h3>Related Posts</h3>'; |
|
|
|
while ( $related->have_posts() ) : |
|
|
|
$ctr++; |
|
|
|
if ( $ctr > 3 ) : |
|
break; |
|
endif; |
|
|
|
|
|
$related->the_post(); |
|
|
|
$category = get_the_category(); |
|
?> |
|
|
|
|
|
<div class="blogroll-post row related-post"> |
|
|
|
<div class="background col-sm-5" |
|
style="background-image: url(<?php echo wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ); ?>)"></div> |
|
|
|
<div class="col-sm-7"> |
|
<h2 class="title"> |
|
|
|
<a href="<?php echo the_permalink(); ?>"> |
|
<?php echo the_title(); ?> |
|
</a> |
|
|
|
<a class="category category-<?php echo $category[0]->cat_ID; ?>" href="<?php echo get_category_link( $category[ 0 ]->cat_ID ); ?>">In <?php echo $category[ 0 ]->name ?></a> |
|
|
|
<div> |
|
<span class="author-by">By </span><span class="author"><?php the_author(); ?></span> |
|
<span class="time"> | <?php echo human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) . ' ago'; ?></span> |
|
|
|
<?php $duration = get_post_meta( get_the_ID(), 'post_duration_mintues', True ); ?> |
|
<?php if ( $duration ) : ?> |
|
<span class="length">| <?php echo get_post_meta( get_the_ID(), 'post_duration_mintues', True ); ?> min read</span> |
|
<?php endif; ?> |
|
</div> |
|
|
|
<div class="clear"></div> |
|
|
|
|
|
</h2> |
|
</div> |
|
|
|
</div> |
|
|
|
|
|
<?php |
|
endwhile; |
|
else : |
|
// no posts found |
|
|
|
endif; |
|
|
|
// Restore original Post Data |
|
wp_reset_postdata(); |