wordpress - Listing search results with tax_query and meta_query -
i can't understand why filter wrote doesn't working when use next or previous page!! example make choice minprice= 200 click on search , filter find post price > 200 when try see rest of post page show me same page. code!!
foreach($_post $key => $value){ if($value != ''){ $item['taxonomy'] = htmlspecialchars($key); $item['terms'] = htmlspecialchars($value); $item['field'] = 'slug'; $list[] = $item; if ($key == "minprice") { $minprice = $key; if($value > 0) { $valminprice = $value; } } if ($key == "maxprice") { $maxprice = $key; if($value > 0) { $valmaxprice = $value; } } if ($key == "minmq") { $minmq = $key; if($value > 0) { $valminmq = $value; } } if ($key == "maxmq") { $maxmq = $key; if($value > 0) { $valmaxmq = $value; } } if($key == "location"){ $lockey = $key; $valloc = $value; } if ($key == "type") { $typekey = $key; $valtype = $value; } if ($key == "property") { $propkey = $key; $valprop = $value; } if ($key == "range") { $rangekey = $key; $valrange = $value; } } } $args = array ( 'post_type' => 'listings', 'posts_per_page' => 2, 'meta_query' => array( array( 'key' => 'wtf_price', 'value' => array($valminprice, $valmaxprice), 'type' => 'numeric', 'compare' => 'between' ), array( 'key' => 'wtf_mq', 'value' => array($valminmq,$valmaxmq), 'type' => 'numeric', 'compare' => 'between' ) ), 'tax_query' => array( array( 'taxonomy' => 'location', 'field' => 'slug', 'terms' => $valloc, ), array( 'taxonomy' => 'type', 'field' => 'slug', 'terms' => $valtype, ), array( 'taxonomy' => 'property', 'field' => 'slug', 'terms' => $valprop, ), array( 'taxonomy' => 'range', 'field' => 'slug', 'terms' => $valrange, ) ) ); $the_query = new wp_query($args); <?php while ( $the_query->have_posts() ) : $the_query->the_post();?> <div class="post propbox <?php if (++$counter % 2 == 0) { echo "lastbox";}?> clearfix" id="post-<?php the_id(); ?>"> <div class="archimg"> content.... </div> <?php endwhile; wp_reset_postdata(); ?> <div class="row page-navigation"> <?php next_posts_link('« next page', $the_query->max_num_pages) ?> <?php previous_posts_link('previous »') ?> </div> </div><!--end content-->`
someone can me please? p.s. sorry terrible english!!
i believe need add paged
parameter query.
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array ( 'post_type' => 'listings', 'posts_per_page' => 2, 'paged' => $paged, // etc. );
this codex article has more samples should going.
Comments
Post a Comment