-
Notifications
You must be signed in to change notification settings - Fork 0
/
page-keywords.php
156 lines (144 loc) · 4.95 KB
/
page-keywords.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
/*
Template Name: Keywords
*/
?>
<?php get_header(); ?>
<div id="content" class="clearfix container1160">
<div id="main" role="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
<header>
<div class="page-header">
<div class="container container620">
<div class="row">
<div class="col-sm-12">
<h1><?php the_title(); ?></h1>
</div>
</div>
</div>
</div>
</header>
<section class="clearfix">
<div class="container container620">
<div class="row">
<div class="col-sm-12">
<h3><?php the_content(); ?></h3>
</div>
</div>
</div>
</section>
<section class="clearfix">
<div class="container container620">
<div class="row mt_25 mb_40">
<div class="col-sm-12">
<?php
$alphabet = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
$args=array(
'post_type' => 'keywords',
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page'=>-1,
'caller_get_posts'=>1
);
$keywords = [];
$query = new WP_Query( $args );
while ($query->have_posts() ) :
$query->the_post();
$group = strtolower(substr(get_the_title(),0,1));
if(! array_key_exists($group, $keywords)){
$keywords[$group] = array();
}
array_push($keywords[$group], array("title"=>get_the_title(), "content" => get_the_content()));
endwhile;
wp_reset_postdata();
foreach ($alphabet as $letter){
$hasEntries = array_key_exists($letter, $keywords) ? "has-entries" : "";
$isFilter = array_key_exists($letter, $keywords) ? "filter" : "";
echo '<div class="sortbyletters '.$hasEntries.'">';
echo ' <h3 class="nomargin uppercase '.$isFilter.'" style="text-transform:uppercase;" data-filter=".letter-'.$letter.'">'.$letter.'</h3>';
echo '</div>';
}
?>
</div>
</div>
</div>
</section>
<section class="clearfix mb_80">
<div class="container">
<div class="row" id="mixUpElements">
<!-- accordion begin -->
<?php foreach ($keywords as $key => $group){ ?>
<div class="keywordsContainer mix letter-<?php echo $key; ?>">
<div class="keywordsLetter">
<h3><?php echo $key; ?></h3>
</div>
<div class="keywordsBody">
<div class="panel-group" id="accordion-<?php echo $key; ?>">
<?php foreach ($group as $index => $keyword){ ?>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion-<?php echo $key; ?>" href="#collapse-<?php echo $key; ?>-<?php echo $index; ?>"><?php echo $keyword['title']; ?></a>
</h4>
</div>
<div id="collapse-<?php echo $key; ?>-<?php echo $index; ?>" class="panel-collapse collapse">
<div class="panel-body"><?php echo $keyword['content']; ?></div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
<!-- accordion end -->
</div>
</div>
</section>
<footer>
<p class="clearfix"><?php the_tags('<span class="tags">' . __("Tags","wpbootstrap") . ': ', ', ', '</span>'); ?></p>
</footer> <!-- end article footer -->
</article> <!-- end article -->
<?php endwhile; ?>
<?php else : ?>
<article id="post-not-found">
<header>
<h1><?php _e("Not Found", "wpbootstrap"); ?></h1>
</header>
<section class="post_content">
<p><?php _e("Sorry, but the requested resource was not found on this site.", "wpbootstrap"); ?></p>
</section>
<footer>
</footer>
</article>
<?php endif; ?>
</div>
</div>
<?php require_once(get_template_directory()."/partials/pagenavigation.php"); ?>
<?php
$loadFilter = isset($wp_query->query_vars['person-tag']) ? ".".urldecode($wp_query->query_vars['person-tag']) : "all";
?>
<script type='text/javascript'>
function jLoaded(){
if (typeof jQuery == 'undefined') {
window.setTimeout("jLoaded",250);
} else {
//console.log(jQuery(document));
jQuery(document).ready(function(){
jQuery('#mixUpElements').mixItUp({
controls: {
toggleFilterButtons: false
},
load: {
filter: '<?php echo $loadFilter; ?>'
}
});
jQuery('#SortSelect').on('change', function(){
jQuery('#mixUpElements').mixItUp('sort', this.value);
});
});
}
}
jLoaded();
</script>
<?php get_footer(); ?>