-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop-alphabet.php
85 lines (53 loc) · 2.1 KB
/
loop-alphabet.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
/**
* Alternate "loop" to display posts in blog style.
*/
<?php
global $bunyad_loop;
if (!is_object($bunyad_loop)) {
$bunyad_loop = $wp_query;
}
if ($bunyad_loop->have_posts()):
$titles = array();
while ($bunyad_loop->have_posts()) {
$bunyad_loop->the_post();
$first_letter = substr(get_the_title(),0,1); /** <-- format so only first letter of venue is returned */
$titles[$first_letter][] = $post;
}
/**
* Attributes and infinite scroll
*/
$attribs = array('class' => 'posts-list list-timeline');
if (Bunyad::options()->pagination_type == 'infinite') {
$attribs['data-infinite'] = Bunyad::markup()->unique_id('listing-');
}
?>
<div <?php Bunyad::markup()->attribs('loop', $attribs); ?>>
<?php foreach ($titles as $title => $the_posts): ?>
<div class="month" data-month="<?php echo esc_attr($first_letter); ?>">
<span class="heading"><?php echo esc_html($first_letter); ?></span>
<div class="posts">
<?php foreach ($the_posts as $post): setup_postdata($post); ?>
<article>
<time datetime="<?php echo get_the_date('Y-m-d\TH:i:sP'); ?>"><?php echo get_the_date('M d'); ?> </time>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</article>
<?php endforeach; wp_reset_postdata(); ?>
</div> <!-- .posts -->
</div>
<?php endforeach; ?>
</div>
<?php if (!Bunyad::options()->blog_no_pagination): // pagination can be disabled ?>
<div class="main-pagination">
<?php echo Bunyad::posts()->paginate(array(), $bunyad_loop); ?>
</div>
<?php endif; ?>
<?php else: ?>
<article id="post-0" class="post no-results not-found">
<header class="post-header">
<h1 class="post-title"><?php _e( 'Nothing Found', 'bunyad' ); ?></h1>
</header><!-- .entry-header -->
<div class="post-content">
<p><?php _e('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'bunyad'); ?></p>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; ?>