-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsingular.php
182 lines (136 loc) · 4.18 KB
/
singular.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php get_header('', array( 'body-classes' => 'blog-post') ); ?>
<main>
<?php while ( have_posts() ) : the_post(); ?>
<header>
<h1><?php the_title(); ?></h1>
<?php if ( get_field('authorship') ) : ?>
<span class="byline">by
<?php
$authors = get_field('authorship');
if( $authors ):
$i = 1;
$count = count($authors);
foreach( $authors as $author ):
$permalink = get_permalink( $author->ID );
$title = get_the_title( $author->ID );
$custom_field = get_field( 'field_name', $author->ID );
if ($i < $count) {
$separator = ',';
}
else {
$separator = '';
}
?>
<a href="<?php echo esc_url( $permalink ); ?>"><?php echo esc_html( $title ); ?></a><?php echo $separator; ?>
<?php $i++; ?>
<?php endforeach; ?>
<?php endif; ?>
</span>
<?php endif; ?>
<!-- <p>lead in paragraph</p> -->
<?php
?>
<span class="categories">
<?php the_category(', ') ?>
</span>
<!-- <img src="#" /> -->
</header>
<div class="content"
<?php if (!class_exists('ACF')): ?>
<!-- display raw post_meta, if ACF not installed & activated -->
<?php if (get_post_meta( get_the_ID(), 'lead_in_copy', true )): ?>
<div class="series">
<?php echo get_post_meta( get_the_ID(), 'lead_in_copy', true ); ?>
</div>
<?php endif; ?>
<?php else : ?>
<!-- display ACF field, if ACF installed & activated -->
<?php if (get_field('lead_in_copy')): ?>
<div class="series">
<?php the_field('lead_in_copy'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php the_content(); ?>
<!-- display ACF field, if ACF installed & activated -->
<?php if (get_field('closing_copy')): ?>
<div class="closing">
<?php the_field('closing_copy'); ?>
</div>
<?php endif; ?>
<span class="pub-date">Posted <?php the_date('d F Y'); ?></span>
<?php
$posttags = get_the_tags();
if ($posttags) :
?>
<article class="tags">
<h2>Tags</h2>
<ul>
<?php foreach($posttags as $tag) : ?>
<li><a href="<?php echo get_tag_link($tag->term_id); ?>"><?php echo $tag->name; ?></a></li>
<?php endforeach; ?>
</ul>
</article>
<?php endif; ?>
<?php
$queried_object = get_queried_object();
$categories = get_the_category( $post->ID );
$catIDs = '';
foreach( $categories as $category) {
$catIDs .= $category->cat_ID . ",";
}
$query = new WP_Query(array(
'cat' => $catIDs,
'post__not_in' => array($queried_object->ID),
'post_type' => 'post',
'posts_per_page' => 4,
//'paged' => $paged,
));
?>
</div>
<?php if ( $query->have_posts() ) : ?>
<article class="posts related">
<h2>Related posts</h2>
<ul>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<li>
<article class="post">
<header>
<h3><a href="<?php echo the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php if ( get_field('authorship') ) : ?>
<span class="byline">by
<?php
$authors = get_field('authorship');
if( $authors ):
$i = 1;
$count = count($authors);
foreach( $authors as $author ):
$permalink = get_permalink( $author->ID );
$title = get_the_title( $author->ID );
$custom_field = get_field( 'field_name', $author->ID );
if ($i < $count) {
$separator = ',';
}
else {
$separator = '';
}
?>
<a href="<?php echo esc_url( $permalink ); ?>"><?php echo esc_html( $title ); ?></a><?php echo $separator; ?>
<?php $i++; ?>
<?php endforeach; ?>
<?php endif; ?>
</span>
<?php endif; ?>
<span class="categories">
<?php the_category(', ') ?>
</span>
</header>
</article>
</li>
<?php endwhile; ?>
</ul>
</article>
<?php endif; ?>
<?php endwhile; // end of the loop. ?>
</main>
<?php get_footer(); ?>