-
Notifications
You must be signed in to change notification settings - Fork 0
/
single.php
executable file
·57 lines (45 loc) · 1.21 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
<?php
/**
* The Template for displaying all single posts.
*/
get_header(); ?>
<div id="primary" class="site-content span9">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'single' ); ?>
<?php endwhile; // end of the loop. ?>
<?php
$tags = wp_get_post_tags( get_the_ID() );
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array(get_the_ID()),
'posts_per_page'=>3, // Number of related posts to display.
'ignore_sticky_posts'=>1
);
$my_query = new WP_Query( $args );
if( $my_query->have_posts() ) { ?>
<div class="related-post">
<h3><?php _e('Related posts','dw_focus') ?></h3>
<div class="row-fluid">
<div class="content-inner">
<?php
while( $my_query->have_posts() ) {
$my_query->the_post();
get_template_part('content', 'related-post');
}
?>
</div>
</div>
</div>
<?php
}
}
?>
<?php while ( have_posts() ) { the_post(); ?>
<?php comments_template( '', true ); ?>
<?php } ?>
</div>
<?php get_sidebar( 'single' ); ?>
<?php get_footer(); ?>