-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop-ct_sermon.php
93 lines (79 loc) · 3.28 KB
/
loop-ct_sermon.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
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/*
===================================================================================================
WARNING! DO NOT EDIT THIS FILE OR ANY TEMPLATE FILES IN THIS THEME!
To make it easy to update your theme, you should not edit this file. Instead, you should create a
Child Theme first. This will ensure your template changes are not lost when updating the theme.
You can learn more about creating Child Themes here: http://codex.wordpress.org/Child_Themes
You have been warned! :)
===================================================================================================
*/
?>
<?php
$sermon_settings = get_option('ct_sermon_settings');
isset($sermon_settings['orderby']) ? $orderby = $sermon_settings['orderby'] : $orderby = null;
isset($sermon_settings['order']) ? $order = $sermon_settings['order'] : $order = null;
if(empty($orderby)) $orderby = 'date';
if(empty($order)) $order = 'DESC';
global $post;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if($orderby == 'views'):
$args=array(
'post_type' => 'ct_sermon',
'post_status' => 'publish',
'paged' => $paged,
'meta_key' => 'Views',
'orderby' => 'meta_value_num',
'order' => $order,
'sermon_speaker' => get_query_var('sermon_speaker'),
'sermon_series' => get_query_var('sermon_series'),
'sermon_service' => get_query_var('sermon_service'),
'sermon_topic' => get_query_var('sermon_topic'),
's' => get_query_var('s'),
);
else:
$args=array(
'post_type' => 'ct_sermon',
'post_status' => 'publish',
'paged' => $paged,
'orderby' => $orderby,
'order' => $order,
'sermon_speaker' => get_query_var('sermon_speaker'),
'sermon_series' => get_query_var('sermon_series'),
'sermon_service' => get_query_var('sermon_service'),
'sermon_topic' => get_query_var('sermon_topic'),
's' => get_query_var('s'),
);
endif;
$query = null;
$query = new WP_Query($args);
$i = 0;
if($query->have_posts()): while($query->have_posts()): $query->the_post();
$i++;
$sermon_speaker = get_the_term_list($post->ID, 'sermon_speaker', '', ' + ');
$img_atts = array(
'alt' => trim(strip_tags($post->post_title)),
'title' => trim(strip_tags($post->post_title)),
);
?>
<div <?php if($i == 1): echo post_class('post ct_sermon first'); else: post_class('post ct_sermon'); endif; ?>>
<div class="date"><?php the_time(get_option('date_format')); ?></div>
<h2><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__('Permalink to %s', 'churchthemes'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php if($sermon_speaker): ?>
<h4><?php echo $sermon_speaker; ?></h4>
<?php endif; ?>
<div class="excerpt">
<?php if(has_post_thumbnail()): ?>
<div class="image mobile-grid-100"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute('echo=0'); ?>" rel="bookmark"><?php echo get_the_post_thumbnail($post->ID, 'archive', $img_atts); ?></a></div>
<?php endif; ?>
<?php the_excerpt(); ?>
</div>
<div class="clear"></div>
</div>
<?php endwhile; else: ?>
<div class="post ct_sermon first">
<h2><?php _e('No results found', 'churchthemes'); ?></h2>
<p><?php _e('Sorry, nothing was found matching that criteria. Please try your search again.', 'churchthemes'); ?></p>
</div>
<?php endif; ?>
<?php if($query->max_num_pages > 1): pagination($query->max_num_pages); endif; wp_reset_query(); ?>