Support » Plugins » Custom query with WP-PageNavi

Viewing 5 replies - 1 through 5 (of 5 total)
  • You need to use a custom query like to return just the post ids of the desired posts, then use those IDs in a ‘post__in’ argument with a new WP_Query (see the Pages article for a sample of a query that paginates}.

    Maybe I should clarify. This is my custom query. It delivers all the posts from the query on the same page. I want to now use the Page-Navi plugin to paginate the results to 5 per page. Is this possible?

    		$querystr = "SELECT P .  * , PM.meta_value as Default_Order
    FROM wp_posts P, wp_postmeta PM, wp_term_relationships PC
    WHERE P.ID = PM.post_id
    AND PM.meta_key = 'Display_Order'
    AND P.post_status = 'publish'
    AND P.post_type = 'post'
    AND PC.object_id = P.ID
    AND PC.term_taxonomy_id = 9
    AND exists (
    	SELECT *
    	FROM wp_postmeta DPM
    	WHERE P.ID = DPM.post_id
    	AND DPM.meta_key = 'Suburb'
    	AND DPM.meta_value = 'Sunshine Beach'
    ORDER BY Default_Order+1 ASC";
    	 	$pageposts = $wpdb->get_results($querystr, OBJECT);
    		<?php if ($pageposts): ?>
    			<?php foreach ($pageposts as $post): ?>
    			<?php setup_postdata($post); ?>
    			<div id="post_feed">
    				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    				<?php the_excerpt(); ?>
    			<?php  endforeach; ?>	
    			<div class="pagenavi">
    				<?php if (function_exists('wp_pagenavi')) { ?><?php wp_pagenavi(); ?><?php } ?>
    		<?php else : ?>
    			<div class="post">
    				<h2><?php _e('No properties have been found. Please try again.'); ?></h2>
    		<?php endif; ?>

    From what I understand, this can’t be done. I gather you have to write your own pagination script. I found this WP pagination help useful.

    Sure it can be done. Run this before the loop:
    <?php query_posts(array('category__not_in' => array(29,30,31), 'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1)); ?>


    I am having a problem with custom queries and the WP-PageNavi plugin. The PageNavi is paging some of my posts but not all of them. For instance, for one custom query by state, I have 1,300 posts and only about 190 of them are getting paged under the custom search query. I will appreciate any help and will happy to compensate anyone that can help me solve this problem! Thank you!

    edit: code removed as per the forum guidelines, please use

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom query with WP-PageNavi’ is closed to new replies.