/
content-main-list.php
72 lines (65 loc) · 1.82 KB
/
content-main-list.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
<?php
/**
* Program listing for an individual category
* Listing is based on multiple groupings, first by Brochure (brochure-editions) taxonomy,
* then the Age Ranges (age-ranges) taxonomy. Within each group, programs are sorted by
* custom meta field State Date (dns_start_date) ascending
*
* @package DNS Programs
* @author Ryan Leeson
*/
global $post;
// Set default page properties
$object = get_queried_object();
$page_name = 'main';
$query_args = array(
'post_type' => 'post',
'post_status' => 'published',
'posts_per_page' => -1
);
// Modify query based on page type
if ( is_author() ) {
$page_name = 'author';
$query_args[ 'author_name' ] = $object->user_nicename;
}
elseif ( is_category() ) {
$page_name = 'category';
$query_args[ 'category_name' ] = esc_attr( $object->slug );
}
// Set properties to build the sort array
$sort_args = array(
'query_args' => $query_args,
'sort_callback' => 'dns_startdate_timestamp'
);
$list_order = dns_double_taxonomy_sort_array( $sort_args );
// Specify the list render properties
$render_args = array ( 'sort_array' => $list_order );
if ( is_home() ) {
$render_args[ 't1_collapse' ] = false;
}
?>
<main class="bs-masthead container <?php echo esc_attr( $page_name ); ?>-list" id="content" role="main">
<?php
// Show an optional Header for specific page types
if ( is_author() ) {
?>
<header class="section-info <?php echo $object->slug; ?>">
<div class="categories">
<h1>Author</h1>
<?php printf( '<p>%s</p>', $object->display_name ); ?>
</div>
</header>
<?php
}
elseif ( is_category() ) {
?>
<header class="section-info <?php echo $object->slug; ?>">
<div class="categories">
<h1>Category</h1>
<?php printf( '<p>%s</p>', $object->name ); ?>
</div>
</header>
<?php
}
dns_double_taxonomy_sort_render( $render_args ); ?>
</main>