Sunday, 2 February 2014

Pagination not working with custom loop

I've got a custom loop that I'm using to display some Real Estate listings that will be available within 60 days. I'm calling it with the following function:
<?php 
$sixtydays
= date('Y/m/d', strtotime('+60 days'));
$paged
= (get_query_var('paged')) ? get_query_var('paged') : 1;
$query
= new PostsOrderedByMetaQuery(array(
'post_type' => array('post', 'real-estate'),
'meta_key' => 'Time Available',
'meta_compare' => '<=',
'meta_value' => $sixtydays,
'paged' => $paged,
'orderby_meta_key' => 'Price',
'orderby_order' => 'ASC'
));
?>
<?php while ($query->have_posts()) : $query->the_post(); ?>
While the loop works great, I can't get it to paginate. It shows the first 10 (my default) posts but doesn't show the pagination. The only way to display all posts is to show them on one page by adding 'posts_per_page' => -1, I have similar loops on other pages that have no problem paginating. The only difference with this one is that there are two meta keys that are filtering the posts.
I'm using WP Page Navi for this and the rest of my pages. I'm closing the loop and adding the pagination using the following code:
<?php endwhile; // End the loop. Whew. ?>
<?php wp_pagenavi(); ?>
<?php wp_reset_query(); ?>
How can I go about fixing this?

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More