-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch1.php
executable file
·170 lines (143 loc) · 3.36 KB
/
search1.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/**
* The template for displaying Search Results pages.
*
* @package Odin
* @since 2.2.0
*/
get_header('banco');
$post_type = get_query_var('post_type');
if (isset($_GET['tema'])) {
$tema=$_GET["tema"];
}
else{
$tema=0;
}
if (isset($_GET['uf'])) {
$uf=$_GET["uf"];
}
else{
$uf=0;
}
if (isset($_GET['cidade'])) {
$cidade=$_GET["cidade"];
}
else{
$cidade=0;
}
if (isset($_GET['s'])&&$_GET['s']!="") {
$nome=$_GET["s"];
add_filter( 'posts_where', 'cf_search_where' );
add_filter('posts_join', 'cf_search_join' );
add_filter( 'posts_distinct', 'cf_search_distinct' );
}
else{
$nome="";
}
if( $post_type == 'pratica'){
$args = array(
's' => $nome,
'post_type' => 'pratica',
'paged' =>get_query_var( 'paged' ),
);
if ($cidade != 0 && $uf !=0){
$args['meta_query']=array(
array(
'key' => 'uf',
'value' => $uf,
'compare' => '=',
),
array(
'key' => 'cidade',
'value' => $cidade,
'compare' => '=',
),
);
}
elseif($cidade!=0){
$args['meta_query']=array(
'relation' => 'OR',
array(
'key' => 'cidade',
'value' => $cidade,
'compare' => '=',
),
);
}
else if ($uf!="0"){
$args['meta_query']=array(
'relation' => 'OR',
array(
'key' => 'uf',
'value' => $uf,
'compare' => '=',
),
);
}
if ($tema !=0){
$args['tax_query']=array(
array(
'taxonomy' => 'tema',
'field' => 'id',
'terms' => $tema,
),
);
}
$query = new WP_Query( $args );
echo '<pre>';
print_r($query);
echo '</pre>';
?>
<main id="content" class="busca-banco banco" tabindex="-1" role="main">
<?php if ( $query->have_posts() ) : ?>
<header class="row page-header">
<h1 class="page-title"><?php printf( __( 'Busca de Práticas', 'odin' ), get_search_query() ); ?></h1>
</header><!-- .page-header -->
<?php
// Start the Loop.
while ( $query->have_posts() ) : $query->the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( 'content', 'pratica-lista' );
endwhile;
// Post navigation.
odin_paging_nav();
else :
// If no content, include the "No posts found" template.
get_template_part( 'content', 'none' );
endif;
?>
</main><!-- #main -->
<?php
}
else{
?>
<main id="content" class="<?php echo odin_classes_page_sidebar(); ?>" tabindex="-1" role="main">
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'odin' ), get_search_query() ); ?></h1>
</header><!-- .page-header -->
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
endwhile;
// Post navigation.
odin_paging_nav();
else :
// If no content, include the "No posts found" template.
get_template_part( 'content', 'none' );
endif;
?>
</main><!-- #main -->
<?php
}
get_footer();