/
search.php
144 lines (102 loc) · 2.71 KB
/
search.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
<section <?php post_class(); ?>>
<header>
<?php get_template_part('templates/page', 'header'); ?>
</header>
<?php
global $query_string; // required
$query_var = get_search_query();
$query_has_results = false;
$args_latin = array(
'post_type' => 'species',
'posts_per_page' => '-1',
'orderby' => 'title',
'order' => 'ASC',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'ct_Latin_text_9c2a',
'value' => get_search_query(),
'compare' => 'LIKE'
)
)
);
$args_badge = array(
'post_type' => 'species',
'posts_per_page' => '-1',
'orderby' => 'title',
'order' => 'ASC',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'ct_Badges_checkbox_110e ',
'value' => get_search_query(),
'compare' => 'LIKE'
)
)
);
$args_synonyms = array(
'post_type' => 'species',
'posts_per_page' => '-1',
'orderby' => 'title',
'order' => 'ASC',
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'nicknames',
'field' => 'slug',
'terms' => array( get_search_query() )
),
array(
'taxonomy' => 'synonyms',
'field' => 'slug',
'terms' => array( get_search_query() )
)
)
);
?>
<!-- Regular search results -->
<?php $posts = query_posts($query_string.'&posts_per_page=-1&post_type=species&orderby=title&order=ASC'); ?>
<?php if (have_posts()) : ?>
<?php $query_has_results = true; ?>
<ul class="species-collection nav">
<?php get_template_part('loop'); ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // reset the query ?>
<!-- Badge results -->
<?php $posts = query_posts($args_latin); ?>
<?php if (have_posts()) : ?>
<?php $query_has_results = true; ?>
<h2>Latinske treff</h2>
<ul class="species-collection nav">
<?php get_template_part('loop'); ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // reset the query ?>
<!-- Badge results -->
<?php $posts = query_posts($args_badge); ?>
<?php if (have_posts()) : ?>
<?php $query_has_results = true; ?>
<h2>Sjømat merket "<?php echo $query_var ?>"</h2>
<ul class="species-collection nav">
<?php get_template_part('loop'); ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // reset the query ?>
<!-- Synonyms results -->
<?php $posts = query_posts($args_synonyms); ?>
<?php if (have_posts()) : ?>
<?php $query_has_results = true; ?>
<h2>Var du på utkikk etter en av disse?</h2>
<ul class="species-collection nav">
<?php get_template_part('loop'); ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // reset the query ?>
<!-- No results -->
<?php if (!$query_has_results) : ?>
<div class="alert">
<?php _e('Sorry, no results were found.', 'roots'); ?>
</div>
<?php endif; ?>
</section>