-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtaxonomy-characters.php
55 lines (50 loc) · 1.96 KB
/
taxonomy-characters.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
<?php
get_header();
$character = ( isset( $wp_query->query_vars['characters'] ) ) ? esc_html( $wp_query->query_vars['characters'] ) : '';
if ( ! empty( $character ) ) {
$args = array(
'post_type' => 'page',
'meta_key' => 'location-overwrite',
'meta_value' => $character,
);
$insertPage = new WP_Query();
$insertPage->query( $args );
if ( $insertPage->have_posts() ) {
while ( $insertPage->have_posts() ) :
$insertPage->the_post();
get_template_part( 'content', 'page' );
endwhile;
$args = array(
'nopaging' => true,
'numberposts' => -1,
'posts_per_page' => -1,
'post_type' => 'comic',
'orderby' => 'post_date',
'order' => 'ASC',
'post_status' => 'publish',
'characters' => $character,
);
$qposts = get_posts( $args );
if ( ! empty( $qposts ) ) {
$output = '<div class="character-stats">';
$first_seen_object = reset( $qposts );
$first_seen_title = $first_seen_object->post_title;
$first_seen_id = $first_seen_object->ID;
$last_seen_object = end( $qposts );
$last_seen_title = $last_seen_object->post_title;
$last_seen_id = $last_seen_object->ID;
if ( $first_seen_id == $last_seen_id ) {
$output .= '<i>' . __( 'Only Appearance:', 'comicpress' ) . '</i> <a href="' . get_permalink( $first_seen_id ) . '">' . $first_seen_title . '</a><br />';
} else {
$output .= '<i>' . __( 'Recent Appearance:', 'comicpress' ) . '</i> <a href="' . get_permalink( $last_seen_id ) . '">' . $last_seen_title . '</a><br />';
$output .= '<i>' . __( 'First Appearance:', 'comicpress' ) . '</i> <a href="' . get_permalink( $first_seen_id ) . '">' . $first_seen_title . '</a><br />';
}
$output .= '</div>';
echo apply_filters( 'comicpress-character-stats', $output );
}
}
wp_reset_query();
}
// this shows what the 'archive' would show, if you don't want the archive underneith the custom page, remove this.
get_template_part( 'archive' );
get_footer();