-
Notifications
You must be signed in to change notification settings - Fork 2
/
single.php
107 lines (71 loc) · 2.16 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
101
102
103
104
105
106
<!--
SINGLE POST / ARTICLE PAGE
-->
<?php get_header(); ?>
<main>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<header>
<p class="meta">
<span class="datetime"><?php printf(__('<time pubdate>%1$s</time>', 'bhass'), get_the_time('M d, Y')); ?></span>
</p>
<p class="meta">
<span class="category"><?php echo get_the_category_list(', '); ?></span>
</p>
<h1><?php the_title(); ?></h1>
<?php if ( get_field('subtitle') ) : ?>
<p class="subheading">
<?php the_field('subtitle'); ?>
</p>
<?php endif; ?>
<p class="meta">
<?php
_e( 'by ', 'bhass' );
if ( function_exists( 'coauthors_posts_links' ) ) {
coauthors_posts_links();
} else {
the_author_posts_link();
}
?>
</p>
</header>
<article class="content-area">
<?php the_content(); ?>
</article>
<?php if ( has_tag() ) : ?>
<section class="tags meta">
<span class="label">Tags:</span>
<?php the_tags(''); ?>
</section>
<?php endif; ?>
<section class="related-posts">
<?php
$orig_post = $post;
global $post;
$categories = get_the_category($post->ID);
if ($categories) {
echo '<h2>You Might Also Like...</h2>';
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
$args = array(
'category__in' => $category_ids,
'post__not_in' => array($post->ID),
'posts_per_page' => 3,
'ignore_sticky_posts' => true
);
$query = new wp_query( $args );
if ( $query->have_posts() ) : while( $query->have_posts() ) {
$query->the_post();
get_template_part('partials/article');
} endif;
}
wp_reset_query();
?>
</section>
<?php
if ( comments_open() || get_comments_number() ) {
comments_template();
}
?>
<?php endwhile; endif; ?>
</main>
<?php get_footer(); ?>