-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patharchive-grid.php
80 lines (79 loc) · 3.54 KB
/
archive-grid.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
<?php
/**
* Blog Archive Template (grid layout, 3 posts per row, without sidebar)
* @package WordPress
* @subpackage Project_Zero
* @since 0.3
*
* This is a catch-all archive template for any archive pages that do not have a specialised template or a custom post template.
* You can find out more about the Template Hierarchy at
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* To create a post archive for a custom post type, save this as archive-{post_type}.php.
* An example can be found in archive-portfolio.php, which works with the 'portfolio' custom post type in the PLUGIN.
*/
get_header();
?>
<section id="archive-title" class="archive-title page-title">
<div class="container">
<h1>
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
<?php /* If this is a category archive */
if ( is_category() ) {
echo sprintf( __( 'Archive for the ‘%s’ category', 'my cat' ), single_cat_title('', false) );
}
/* If this is a tag archive */
elseif( is_tag() ) {
echo sprintf( __( 'Posts tagged ‘%s’', 'my tag' ), single_tag_title('', false) );
}
/* If this is a daily archive */
elseif ( is_day() ) {
echo sprintf( __( 'Archive for %s', 'my date' ), get_the_time('F jS, Y') );
}
/* If this is a monthly archive */
elseif ( is_month() ) {
echo sprintf( __( 'Archive for %s', 'my date' ), get_the_time('F, Y') );
}
/* If this is a yearly archive */
elseif ( is_year() ) {
echo sprintf( __( 'Archive for %s', 'my date' ), get_the_time('Y') );
}
/* If this is an author archive */
elseif ( is_author() ) {
echo sprintf( __( 'Archive for %s', 'my author' ), get_the_author() );
}
/* If this is a paged archive */
elseif ( isset( $_GET['paged'] ) && !empty( $_GET['paged'] ) ) {
echo __( 'Blog archives' );
} ?>
</h1>
</div> <!-- .container -->
</section> <!-- #archive-title -->
<section id="blog-archive" class="blog-archive archive-page page-container">
<div class="container row">
<main id="archive-content" class="blog-posts row">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
/**
* Loads a reusable section of code from within your child theme.
* If the template part is not within your child theme, it will look within the parent theme.
*
* @link https://developer.wordpress.org/reference/functions/get_template_part/
*
* @param string $slug The slug name for the generic template. Required.
* @param string $name The name of the specialised template.
* @param array $args Additional arguments to be passed through to the template.
*
* The function looks for the file {$slug}-{$name}.php.
* In this instance, it looks for inc/parts/post-archive_3up.php
*/
get_template_part( 'inc/parts/post', 'archive_3up' ); ?>
<?php endwhile; // Stops looping through the posts in WP_Query ?>
<?php blog_archive_pagination(); ?>
<?php else : // If there are no posts in the loop ?>
404
<?php endif; // Ends the loop ?>
</main> <!-- #archive-content -->
</div> <!-- .container -->
</section> <!-- #blog-archive -->
<?php get_footer(); ?>