-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive.php
58 lines (52 loc) · 2.45 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
<?php get_header(); ?>
<?php echo the_core()->get_rendered_monthly_archive_menu(); ?>
<div id="archives_block">
<h1 class="archive-title">
<?php
if ( is_day() ) {
printf( __( 'Daily Archives: %s', 'odyssey' ), '<span>' . get_the_date() . '</span>' );
} else if ( is_month() ) {
printf( __( 'Monthly Archives: %s', 'odyssey' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'odyssey' ) ) . '</span>' );
} else if ( is_year() ) {
printf( __( 'Yearly Archives: %s', 'odyssey' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'odyssey' ) ) . '</span>' );
} else if ( is_category() ) {
printf( __( 'Category Archives: %s', 'odyssey' ), '<span>' . single_cat_title( '', false ) . '</span>' );
} else {
_e( 'Archives', 'odyssey' );
};
?>
</h1>
<ul>
<?php
query_posts( $query_string . '&posts_per_page=-1' );
while ( have_posts() ) { /* Start the Loop */
the_post();
echo '<li>' . PHP_EOL;
// try first to get the post thumbnail
if ( has_post_thumbnail( ) ) {
$post_thumbnail_id = get_post_thumbnail_id( );
} else { // then try to get the first attachment thumbnail
$args = array(
'numberposts' => 1,
'order' => 'ASC',
'post_mime_type' => 'image',
'post_parent' => $post->ID,
'post_status' => null,
'post_type' => 'attachment'
);
$attachments = get_children( $args );
if ($attachments) {
$attachment = current($attachments);
$post_thumbnail_id = $attachment->ID;
}
}
$thumbnail = wp_get_attachment_image_src( $post_thumbnail_id, 'thumbnail' );
echo ' <a class="thumbnail" href="' . get_permalink() .
'" title="' . get_the_title() .
'" style="background-image: url(' . $thumbnail[0] . ')"></a>' . PHP_EOL;
echo '</li>' . PHP_EOL;
}
?>
</ul>
</div>
<?php get_footer(); ?>