-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsidebar.php
67 lines (62 loc) · 1.48 KB
/
sidebar.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
<!-- sidebar -->
<div class="single-sidebar">
<div class="wrapper">
<?php if (is_active_sidebar('sidebar-1')) { ?>
<div id="sidebar-one">
<?php dynamic_sidebar('sidebar-1'); ?>
</div>
<?php } ?>
</div>
<div class="group-heading">
<h3>
<?php
$cat = get_theme_mod('side_category_5');
$cat = get_category($cat);
$cat_post = '';
if (is_wp_error($cat)) { // category is not set
$cat_post = 'uncategorized';
} else {
$cat_post = $cat->slug;
echo $cat->name;
}
if (empty($cat_post)) { //check if category is set
$cat_post = 'uncategorized';
}
?>
<!-- Popular Posts -->
</h3>
</div>
<div class="sidebar">
<div class="popular-post-container">
<div class="post-group popular-post">
<?php
// pull 4 posts
$args = array(
'post_type' => 'post',
'posts_per_page' => '4',
'category_name' => $cat_post,
);
$query = new WP_Query($args);
?>
<?php if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>
<?php
if (!is_sticky()) {
get_template_part('template-parts/posts/post', 'article');
}
?>
<?php endwhile;
wp_reset_postdata();
else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div>
</div>
</div>
<div class="wrapper">
<?php if (is_active_sidebar('sidebar-2')) { ?>
<div id="sidebar-two">
<?php dynamic_sidebar('sidebar-2'); ?>
</div>
<?php } ?>
</div>
</div>