-
Notifications
You must be signed in to change notification settings - Fork 3
/
archive.php
139 lines (112 loc) · 3.16 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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php get_header(); ?>
<?php
$termid = get_queried_object_id();
$color_code = get_term_meta( $termid, 'color_code', true );
?>
<div class="category-header" style="background:<?php echo $color_code; ?>">
<div class="container">
<span style="color:white" class="dashicons <?php echo get_term_meta( $termid, 'icon_slug', true ); ?>"></span>
<span class="category-header-title">
<?php
if ( is_category() ) {
single_cat_title();
} if ( is_tag() ) {
single_tag_title(); }
?>
</span>
<p style="">
<?php
if ( is_category() or is_tag() ) {
echo category_description(); }
?>
</p>
</div>
</div>
<div class="container index-container">
<div class="row">
<div class="col-md-3 sidebar_index">
<?php include( 'sidecategories.php' ); ?>
<?php //dynamic_sidebar('Sidebar_Index'); ?>
</div>
<div class="col-md-9">
<?php
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
?>
<a href="<?php the_permalink(); ?>" class="forum-post-index">
<span class="forum-post-index-comment-count">
<span
class="dashicons dashicons-welcome-comments"></span><?php echo get_comments_number( $post->ID ); ?>
</span>
<span class="forum-post-index-category">
<?php
$categories = get_the_terms( $post->ID, 'category' );
$i = 1;
foreach ( $categories as $c ) {
$termid = $c->term_id;
$color_code = get_term_meta( $termid, 'color_code', true );
echo '<span style="background:' . $color_code . '">' . $c->name . '</span>';
if ( ++$i > 3 ) {
break;
}
}
?>
</span>
<div class="forum-post-index-avatar"><?php echo get_avatar( get_the_author_meta( 'ID' ), 50 ); ?></div>
<div href="<?php the_permalink(); ?>" class="forum-post-index-title"><?php the_title(); ?> </div>
<span class="forum-post-index-author"><b><?php the_author(); ?></b>
<?php
$t = get_the_time( 'U' );
//phpcs:disable
echo human_time_diff( $t, current_time( 'U' ) ) . __( ' ago', 'siforum' );
//phpcs:enable
?>
</span>
</a>
<?php
endwhile; else :
?>
<p><?php esc_html_e( 'No posts here.' ); ?></p><?php endif; ?>
<?php
global $wp_query;
if ( $wp_query->max_num_pages > 1 ) {
echo '<div class="load_more_posts">' . __( 'Load More', 'siforum' ) . '</div>';
}
?>
</div>
</div>
</div>
<script>
jQuery(function($) {
$('.load_more_posts').click(function() {
var button = $(this),
data = {
'action': 'loadmore',
'query': misha_loadmore_params.posts,
'page': misha_loadmore_params.current_page
};
$.ajax({
url: misha_loadmore_params.ajaxurl,
data: data,
type: 'POST',
beforeSend: function(xhr) {
button.text('<?php _e( 'Loading...', 'siforum' ); ?>...');
},
success: function(data) {
if (data) {
button.text('<?php _e( 'Load More', 'siforum' ); ?>').prev().before(
data);
misha_loadmore_params.current_page++;
if (misha_loadmore_params.current_page == misha_loadmore_params
.max_page)
button.remove();
} else {
button.remove();
}
}
});
});
});
</script>
<?php get_footer(); ?>