-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage-archive.php
More file actions
59 lines (53 loc) · 1.74 KB
/
Copy pathpage-archive.php
File metadata and controls
59 lines (53 loc) · 1.74 KB
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
<?php
/**
* Archive page grouped by month.
*
* Template Name: Fireblog Monthly Archive
*
* Create a page with the slug "archive" to use this template automatically.
*
* @package FireblogClassic
*/
get_header();
$archive_query = new WP_Query(
array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC',
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
)
);
$current_month = '';
?>
<section class="archive-index">
<form class="archive-search" role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label class="screen-reader-text" for="archive-search-field"><?php esc_html_e( 'Search', 'fireblog-classic' ); ?></label>
<input id="archive-search-field" name="s" type="text" value="<?php echo esc_attr( get_search_query() ); ?>">
<input type="submit" value="<?php esc_attr_e( 'Search', 'fireblog-classic' ); ?>">
</form>
<?php if ( $archive_query->have_posts() ) : ?>
<?php while ( $archive_query->have_posts() ) : ?>
<?php
$archive_query->the_post();
$post_month = get_the_date( 'F Y' );
if ( $post_month !== $current_month ) :
$current_month = $post_month;
?>
<h2 class="archive-month"><?php echo esc_html( $current_month ); ?></h2>
<?php endif; ?>
<p class="archive-entry">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<small><?php echo esc_html( fireblog_classic_post_short_date() ); ?></small>
</p>
<?php endwhile; ?>
<?php else : ?>
<p><?php esc_html_e( 'No posts found.', 'fireblog-classic' ); ?></p>
<?php endif; ?>
</section>
<?php
wp_reset_postdata();
get_footer();