-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
157 lines (124 loc) · 4.32 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
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php get_header();
/*
Template Name: Search Page
*/
global $query_string;
wp_parse_str($query_string, $search_query);
$search = new WP_Query( $search_query);
if (!isset($_GET['empresa'])) {
$id_empresa_get = "null";
} else{
$id_empresa_get = $_GET['empresa'];
};
if (!isset($_GET['ciudad'])) {
$id_ciudad_get = "null";
} else{
$id_ciudad_get = $_GET['ciudad'];
};
?>
<div class="row cuerpo" id="inicio" >
<div class="row seccion-pagina">
<div class="cuadricula" style="padding-left: 20px;"><br>
<?php get_search_form(); ?>
<h3>Resultados para la búsqueda: <?php echo '"'.$s.'"'; ?></h3>
<br>
<?php
$id_empresa_get = $s;
if($id_empresa_get == 'null' && $id_ciudad_get == 'null'):
$trabajos = get_posts( array(
'post_type' => 'trabajos_pt',
'posts_per_page' => -1,
'orderby' => 'post_date',
'order' => 'DESC',
) );
elseif($id_empresa_get != 'null' && $id_ciudad_get == 'null'):
$trabajos = get_posts( array(
'post_type' => 'trabajos_pt',
'posts_per_page' => -1,
'orderby' => 'post_date',
'meta_key' => 'empresa_relacionada_meta' ,
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'empresa_relacionada_meta',
'value' => $id_empresa_get,
'compare' => 'LIKE',
)
)
) );
elseif($id_empresa_get == 'null' && $id_ciudad_get != 'null'):
$trabajos_all = get_posts( array(
'post_type' => 'trabajos_pt',
'posts_per_page' => -1,
'orderby' => 'post_date',
'order' => 'DESC',
) );
$trabajos= array();
foreach($trabajos_all as $trabajo):
$sucursal_relacionada = get_post_meta( $trabajo->ID, 'sucursal_relacionada_meta', true );
$sucursal_relacionada = $sucursal_relacionada[0];
$nombre_ciudad = get_post_meta( $sucursal_relacionada, 'datos_sucursal_meta_ciudad', true );
if($nombre_ciudad == $id_ciudad_get) {
array_push($trabajos, $trabajo );
}
endforeach;
elseif($id_empresa_get != 'null' && $id_ciudad_get != 'null'):
$trabajos_all = get_posts( array(
'post_type' => 'trabajos_pt',
'posts_per_page' => -1,
'orderby' => 'post_date',
'meta_key' => 'empresa_relacionada_meta' ,
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'empresa_relacionada_meta',
'value' => $id_empresa_get,
'compare' => 'LIKE',
)
)
) );
$trabajos= array();
foreach($trabajos_all as $trabajo):
$sucursal_relacionada = get_post_meta( $trabajo->ID, 'sucursal_relacionada_meta', true );
$sucursal_relacionada = $sucursal_relacionada[0];
$nombre_ciudad = get_post_meta( $sucursal_relacionada, 'datos_sucursal_meta_ciudad', true );
if($nombre_ciudad == $id_ciudad_get) {
array_push($trabajos, $trabajo );
}
endforeach;
endif;
if(!empty($trabajos)):
foreach($trabajos as $trabajo):
$empresa_relacionada = get_post_meta( $trabajo->ID, 'empresa_relacionada_meta', true );
$empresa_relacionada = $empresa_relacionada[0];
$sucursal_relacionada = get_post_meta( $trabajo->ID, 'sucursal_relacionada_meta', true );
$sucursal_relacionada = $sucursal_relacionada[0];
?>
<div class="cuadro medio-6 grande-12 chico-12 slider-home cuadro-trabajo" style="margin-bottom: 20px;border-bottom: 20px solid
<?php echo get_post_meta( $empresa_relacionada, 'color_destacado_meta', true ); ?>;"> <!-- Color Estilo -->
<b><?php echo get_the_title( $trabajo->ID ); ?></b><br><br> <!-- Imprime Puesto -->
<?php echo get_the_title( $empresa_relacionada); ?><br><br> <!-- Imprime Empresa -->
<p class="fa fa-map-marker"> <?php echo get_the_title ($sucursal_relacionada); ?> </p><br><!-- Imprime Ubicacion-->
<a href="<?php echo get_permalink($trabajo->ID); ?>">Ver mas</a>
<!-- echo "<a href='$link' title='$linktitle'>$linkname</a>"; -->
</div>
<?php endforeach; else:echo "No hay vacantes disponibles para esta busqueda!"; endif?>
<!--FIN FOREACH-->
</div>
</div>
</div>
<!-- <?php echo $search_query = get_search_query(); ?> -->
<?php
$args = array(
'post_type' => 'trabajos_pt',
// 's' => $s,
);
$results = new WP_Query($args);
foreach ($results->posts as $post) {
// echo $post->post_title;
}
wp_reset_postdata();
?>
</div>
</div>
<?php get_footer(); ?>