forked from argoproject/Argo
-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
archive.php
153 lines (138 loc) · 4.91 KB
/
archive.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
<?php
/**
* Template for various non-category archive pages (tag, term, date, etc.)
*
* @package Largo
* @since 0.1
* @filter largo_partial_by_post_type
*/
get_header();
$queried_object = get_queried_object();
?>
<div class="clearfix">
<?php
if ( have_posts() || largo_have_featured_posts() ) {
// queue up the first post so we know what type of archive page we're dealing with.
the_post();
/*
* Display some different stuff in the header
* depending on what type of archive page we're looking at
*/
if ( is_author() ) {
$rss_link = get_author_feed_link( get_the_author_meta( 'ID' ) );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
$description = tag_description();
$rss_link = get_tag_feed_link( get_queried_object_id() );
} elseif ( is_tax() ) {
$title = single_term_title( '', false );
$description = term_description();
// rss links for custom taxonomies are a little tricky.
$term_id = intval( $queried_object->term_id );
$tax = $queried_object->taxonomy;
$rss_link = get_term_feed_link( $term_id, $tax );
} elseif ( is_date() ) {
$description = __( 'Select a different month:', 'largo' );
if ( is_month() ) {
// translators: this is the PHP date format string for the month and year. Passed to get_the_date(). https://www.php.net/manual/en/datetime.formats.date.php .
$date_format = __( 'F Y', 'largo' );
// translators: %s is the month and year.
$title = sprintf( __( 'Monthly Archives: <span>%s</span>', 'largo' ), get_the_date( $date_format ) );
} elseif ( is_year() ) {
// translators: this is the PHP date format string for the year. Passed to get_the_date(). https://www.php.net/manual/en/datetime.formats.date.php .
$date_format = __( 'Y', 'largo' );
// translators: %s is the year.
$title = sprintf( __( 'Yearly Archives: <span>%s</span>', 'largo' ), get_the_date( $date_format ) );
} else {
$title = esc_html_e( 'Blog Archives', 'largo' );
}
} elseif ( is_post_type_archive() ) {
$post_type = $wp_query->query_vars['post_type'];
/**
* Make the title of the post_type archive filterable
*
* @param string $title The title of the archive page
* @since 0.5.4
*/
$title = apply_filters(
'largo_archive_' . $post_type . '_title',
post_type_archive_title( '', false )
);
/**
* Make the feed url of the post_type archive filterable
*
* @param string $title The title of the archive page
* @since 0.5.5
*/
$rss_link = apply_filters(
'largo_archive_' . $post_type . '_feed',
site_url( '/feed/?post_type=' . rawurlencode( $post_type ) )
);
}
?>
<header class="archive-background clearfix">
<?php
if ( isset( $rss_link ) ) {
printf(
'<a class="rss-link rss-subscribe-link" href="%1$s">%2$s <i class="icon-rss"></i></a>',
esc_attr( $rss_link ),
esc_html_x( 'Subscribe', 'rss link', 'largo' )
);
}
if ( is_object( $queried_object ) ) {
largo_hero( largo_get_term_meta_post( $queried_object->taxonomy, $queried_object->term_id ) );
}
if ( isset( $title ) ) {
echo '<h1 class="page-title">' . esc_html( $title ) . '</h1>';
}
if ( isset( $description ) ) {
echo '<div class="archive-description">' . wp_kses_post( $description ) . '</div>';
}
if ( is_date() ) {
?>
<nav class="archive-dropdown">
<select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php esc_html_e( 'Select Month', 'largo' ); ?></option>
<?php
wp_get_archives(
array(
'type' => 'monthly',
'format' => 'option',
)
);
?>
</select>
</nav>
<?php
} elseif ( is_author() ) {
the_widget( 'largo_author_widget', array( 'title' => '' ) );
}
?>
</header>
<div class="row-fluid clearfix">
<div class="stories span8" role="main" id="content">
<?php do_action( 'largo_archive_before_stories' ); ?>
<?php
// Having previously pulled the first post to get information about the taxonomy,
// we now wind the posts back so we can go through the loop as usual.
rewind_posts();
$counter = 1;
while ( have_posts() ) {
the_post();
$post_type = get_post_type();
$partial = largo_get_partial_by_post_type( 'archive', $post_type, 'archive' );
get_template_part( 'partials/content', $partial );
do_action( 'largo_loop_after_post_x', $counter, $context = 'archive' );
$counter++;
}
largo_content_nav( 'nav-below' );
?>
</div><!-- end content -->
<?php get_sidebar(); ?>
</div>
<?php } else {
get_template_part( 'partials/content', 'not-found' );
}
?>
</div>
<?php get_footer();