0

I am using meta query to filter posts by various meta tags, showing 9 posts/page, but on pagination there are as many pages as were all the posts displayed without filtering, only that empty pages are shown where the posts are filtered out.

this is my loop, it is in home.php

<?php

$prop_args = array (
    'posts_per_page'=> 9,
    'paged'     => $paged,
    'meta_query'    => array(   
    )
);

if (!empty($camere)) { $prop_args['meta_query'][] = array('key' => 'rooms', 'value' => $camere, 'compare' => '=' ); }
if (!empty($etaj)) { $prop_args['meta_query'][] = array('key' => 'floor', 'value' => $etaj, 'compare' => '=' ); }

$prop_qerry =  new WP_Query ( $prop_args );

if ( $prop_qerry -> have_posts()) {
    while ( $prop_qerry -> have_posts()) {
        $prop_qerry -> the_post(); 
        ?>
        <div class = "property-item">           
        <div class = "prop-list-title"> <?php the_title(); ?> </div>
        <?php get_first_image(); ?>
        <div class = "price"><?php echo get_post_meta( get_the_ID(), 'price', true ); ?></div>
        <div class = "excerpt-list"> 
            <?php 
            $postid = get_the_ID();
            $excerpt = get_post_meta( $postid, 'surface_useable', true ) . " mp, " .get_post_meta( $postid, 'rooms', true ) . " camere, et " . get_post_meta( $postid, 'floor', true ) . ", zona " . get_post_meta( $postid, 'zone', true ); ?> 
            <?php echo $excerpt ?>
        </div> <!-- .excerpt-list -->
        </div> <!-- .property-item -->
        <?php
    }

}

?>
<div class="navigation"><p><?php posts_nav_link(); ?></p></div>
  • please post your code – Michael Jul 28 '19 at 21:44
  • if I just override the main query with: query_posts( $prop_args ); than it`s ok – Botond Vajna Jul 29 '19 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.