forked from WPBuddy/largo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive.php
128 lines (114 loc) · 4.06 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
<?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() ) {
$title = sprintf( __( 'Monthly Archives: <span>%s</span>', 'largo' ), get_the_date( 'F Y' ) );
} elseif ( is_year() ) {
$title = sprintf( __( 'Yearly Archives: <span>%s</span>', 'largo' ), get_the_date( 'Y' ) );
} else {
$title = _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 ), 'largo' )
);
/**
* 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=' . urlencode($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>', $rss_link, __( 'Subscribe', 'largo' ) );
}
$post_id = largo_get_term_meta_post( $queried_object->taxonomy, $queried_object->term_id );
largo_hero($post_id);
if ( isset( $title ) ) {
echo '<h1 class="page-title">' . $title . '</h1>';
}
if ( isset( $description ) ) {
echo '<div class="archive-description">' . $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 _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
// and finally 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++;
endwhile;
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();