-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpage_blog.php
222 lines (166 loc) · 5.8 KB
/
page_blog.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php /* Template Name: Index - Blog */ ?>
<?php get_header('', array( 'body-classes' => 'blog-index') ); ?>
<main>
<header>
<h1>Blog</h1>
<!-- <span class="byline">by <a href="#">Brigitte Vezina</a>, <a href="#">Ony Anukem</a></span> -->
<?php
$introduction = get_field('introduction');
if( $introduction ):
?>
<p><?php echo esc_html( $introduction ); ?></p>
<?php endif; ?>
<!-- <span class="categories">
<a href="#">Open Culture</a>
</span> -->
<!-- <img src="#" /> -->
</header>
<?php
$posts = get_field('featured_posts');
if( $posts ):
?>
<article class="posts featured">
<h2>Featured posts</h2>
<ul>
<?php
$i=1;
foreach( $posts as $post ):
$permalink = get_permalink( $post->ID );
$title = get_the_title( $post->ID );
//$custom_field = get_field( 'field_name', $post->ID );
?>
<li>
<article class="post">
<header>
<h3 class="title"><a href="<?php echo esc_url( $permalink ); ?>"><?php echo esc_html( $title ); ?></a></h3>
<?php if ( get_field('authorship') ) : ?>
<span class="byline">by
<?php
$authors = get_field('authorship');
if( $authors ):
$ai = 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 ($ai < $count) {
$separator = ',';
}
else {
$separator = '';
}
?>
<a href="<?php echo esc_url( $permalink ); ?>"><?php echo esc_html( $title ); ?></a><?php echo $separator; ?>
<?php $ai++; ?>
<?php endforeach; ?>
<?php endif; ?>
</span>
<?php endif; ?>
<span class="categories">
<?php the_category(', ') ?>
</span>
</header>
<figure>
<?php //echo get_the_post_thumbnail( $post_id, 'full' );
?>
<img src="<?php echo get_the_post_thumbnail_url( $post_id, 'large' ); ?>" alt="<?php echo get_post_meta ( get_post_thumbnail_id($post_id), '_wp_attachment_image_alt', true ); ?>" />
<?php if ($i == 1): ?>
<figcaption class="attribution"><?php echo get_the_post_thumbnail_caption( $post_id ); ?></figcaption>
<?php endif; ?>
</figure>
<?php if ($i == 1): ?>
<?php the_excerpt(); ?>
<?php endif; ?>
</article>
</li>
<?php
// if ($i != 1) {
$highlight_posts[] = $post->ID;
// }
$i++;
?>
<?php endforeach; ?>
</ul>
</article>
<?php endif; ?>
<article class="posts">
<h2>Recent Posts</h2>
<ul>
<?php
$query = new WP_Query(array(
'post__not_in' => $highlight_posts,
'post_type' => 'post',
'posts_per_page' => 6,
//'paged' => $paged,
));
?>
<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<li>
<article class="post">
<header>
<h3 class="title"><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>
<figure>
<?php //echo get_the_post_thumbnail( $post_id, 'full' );
?>
<img src="<?php echo get_the_post_thumbnail_url( $post_id, 'large' ); ?>" alt="<?php echo get_post_meta ( get_post_thumbnail_id($post_id), '_wp_attachment_image_alt', true ); ?>" />
</figure>
</article>
</li>
<?php $highlight_posts[] = $post->ID; ?>
<?php endwhile; ?>
</ul>
<a class="more" href="/blog/archive/">more posts</a>
<?php endif; ?>
</article>
<footer>
<article class="attribution-list">
<?php array_shift($highlight_posts); ?>
<h2>Images Attri­bution</h2>
<button class="expand-attribution">view</button>
<ul class="attribution-panel">
<?php foreach ($highlight_posts as $item) : ?>
<?php if( get_the_post_thumbnail_caption( $item ) ) : ?>
<li>
<article>
<figure>
<img src="<?php echo get_the_post_thumbnail_url( $item, 'medium' ); ?>" alt="<?php echo get_post_meta ( get_post_thumbnail_id($item), '_wp_attachment_image_alt', true ); ?>" />
<figcaption class="attribution"><?php echo get_the_post_thumbnail_caption( $item ); ?></figcaption>
</figure>
</article>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</article>
</footer>
</main>
<?php get_footer(); ?>