-
Notifications
You must be signed in to change notification settings - Fork 1
/
single.php
100 lines (74 loc) · 2.03 KB
/
single.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
*
* This is the template that displays single posts
*
* @package MIT_Libraries_Child
* @since 2.1.0
*/
get_header( 'child' );
get_template_part( 'inc/breadcrumbs', 'child' );
?>
<div id="stage" class="inner" role="main">
<?php get_template_part( 'inc/postHead' ); ?>
<div id="content" class="content has-sidebar">
<div class="content-main main-content">
<?php while ( have_posts() ) : the_post();
$current_post_id = $post->ID;
?>
<div class="article-head">
<h2 class="entry-title"><?php the_title(); ?></h2>
<p class="entry-meta">
Posted on <?php the_date(); ?> in <?php the_category( ', ' ); ?>
</p>
</div>
<div class="entry-content clearfix">
<?php the_content(); ?>
</div>
<ul class="post-navigation">
<li><?php previous_post_link( '%link', 'Previous', 'no' ); ?></li>
<li><?php next_post_link( '%link', 'Next', 'no' ); ?></li>
</ul>
<?php endwhile; // End of the loop. ?>
<?php
global $post;
$tags = wp_get_post_tags( $current_post_id );
$tagcount = count( $tags );
if ( $tagcount > 0 ) {
$tag_ids = array();
foreach ( $tags as $individual_tag ) {
$tag_ids[] = $individual_tag->term_id;
$args = array(
'tag__in' => $tag_ids,
'post__not_in' => array( $current_post_id ),
'posts_per_page' => 3,
);
}
$related_query = new WP_Query( $args );
if ( $related_query->have_posts() ) :
?>
<hr/>
<div>
<h3>Related posts</h3>
<ul class="relateds">
<?php
while ( $related_query->have_posts() ) : $related_query->the_post(); ?>
<li class="related">
<?php the_post_thumbnail( array( 100, 100 ) ); ?>
<a class="related-title" href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</li>
<?php endwhile; ?>
</ul>
</div>
<?php endif;?>
<?php
}
wp_reset_query();
?>
</div>
<?php get_sidebar(); ?>
</div>
</div><!-- end div#stage -->
<?php get_footer(); ?>