-
Notifications
You must be signed in to change notification settings - Fork 0
/
content-related-articles.php
72 lines (55 loc) · 1.63 KB
/
content-related-articles.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!-- RELATED ARTICLES -->
<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {?>
<section class="block articles related">
<h2 class="title">Related Articles</h2>
<ul class="articles">
<?php
$first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
'post__not_in' => array($post->ID),
'posts_per_page'=>5,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
$ctr = 0;
while ($my_query->have_posts()) : $my_query->the_post();
$my_query_postid = get_the_ID();
?>
<li class="article<?php if ($ctr == 0) { echo " grid-sizer"; }?>">
<?php
if ( has_post_thumbnail() ) {
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($my_query_postid), 'thumbnail_size' );
$thumb_url = $thumb['0'];
?>
<!-- featured image -->
<a class="photo" href="<?php echo $thumb_url?>">
<?php
the_post_thumbnail( 'medium' );
?>
</a>
<?php
}
?>
<div class="details">
<!-- title -->
<h3 class="title"><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<!-- publish date -->
<time datetime="<?php echo get_the_date( "Y-m-d h:ia" ); ?>"><?php echo get_the_date(); ?></time>
<!-- excerpt -->
<?php the_excerpt(); ?>
</div>
</li>
<?php
$ctr++;
endwhile;
}
wp_reset_query();
?>
</ul>
</section>
<!-- /RELATED ARTICLES -->
<?php } ?>