First of all thank you everyone for all the knowledge base i got reading trough stackexchange. For the first time i couldn't find an answer to my problem.
The matter is that with this custom query (which has the purpose to search trough the posts with multiple taxonomy fields):
global $wp_query;
$tax_query = array();
$parametri = array(
'ih_tipo_struttura' => array('tipo_struttura','IN'),
'ih_localita' => array('localita', 'IN'),
'ih_stelle' => array('stelle', 'IN'),
'ih_categorie' => array('categorie', 'AND'),
'ih_servizi' => array('servizi', 'AND')
);
// Faccio il post dei parametri e li inserisco nella query
foreach ($parametri as $post => $taxonomy) {
if ( isset($_GET[$post]) && !empty($_GET[$post]) ){
$tax_query[] = array(
'taxonomy' => $taxonomy[0],
'field' => 'slug',
'terms' => $_GET[$post],
'operator' => $taxonomy[1]
);
}
}
// Parametri base della query
$args = array(
'post_type' => 'post',
'tax_query' => $tax_query
);
// Parametri paginazione
if ( $pagination ) {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args['posts_per_page'] = 2;
$args['paged'] = $paged;
} else {
$args[] = array( 'posts_per_page' => 20); // Se imposto la paginazione a false ritorno i primo 20 risultati
}
// Eseguo la query
$wp_query = new WP_Query( $args );
return $wp_query;
everything works fine until i try to do some pagination.
When i pass trough the url some $_GET parameters like:
http://mywebsite/ricerca/?ih_localita%5B%5D=riccione&ih_localita%5B%5D=rimini&ricerca_hotel=true
or
http://mywebsite/ricerca/page/2/?ih_localita=riccione&ih_localita%5B%5D=rimini&ricerca_hotel=true
there's no problem but if try:
http://mywebsite/ricerca/page/2/?ih_localita%5B0%5D=riccione&ih_localita%5B1%5D=rimini&ricerca_hotel=true
wordpress cut off all the search parameters returning the url just like:
http://mywebsite/ricerca/page/2/?ricerca_hotel=true
I'm getting crazy with this so i would really appreciate any help.
Thx