forked from billerickson/EA-Starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive.php
61 lines (50 loc) · 1.35 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
<?php
/**
* Archive
*
* @package EAStarter
* @author Bill Erickson
* @since 1.0.0
* @license GPL-2.0+
**/
/**
* Body Class
*
*/
function ea_archive_body_class( $classes ) {
$classes[] = 'archive';
return $classes;
}
add_filter( 'body_class', 'ea_archive_body_class' );
/**
* Archive Header
*
*/
function ea_archive_header() {
$title = $subtitle = $description = false;
if( is_home() ) {
$title = get_the_title( get_option( 'page_for_posts' ) );
} elseif( is_search() ) {
$title = 'Search Results for: <em>' . get_search_query() . '</em>';
} elseif( is_archive() ) {
$title = get_the_archive_title();
$description = get_the_archive_description();
}
if( empty( $title ) && empty( $description ) )
return;
if( get_query_var( 'paged' ) ) {
global $wp_query;
$subtitle = 'Page ' . get_query_var( 'paged' ) . ' of ' . $wp_query->max_num_pages;
}
echo '<header class="archive-intro">';
if( ! empty( $title ) )
echo '<h1 class="archive-title">' . $title . '</h1>';
if( !empty( $subtitle ) )
echo '<h4>' . $subtitle . '</h4>';
if( ! empty( $description ) )
echo '<div class="archive-description">' . apply_filters( 'ea_the_content', $description ) . '</div>';
echo '</header>';
}
add_action( 'tha_content_while_before', 'ea_archive_header' );
// Build the page
require get_template_directory() . '/index.php';