Update page count in loop

2019-08-27 23:52发布

I have one condition in my loop that is skip multiple record for display.

For example the wp_pagenavi thinks it's 3 pages rather than 2 pages.

I want update page count after loop end.

<?php

$arg = array(
    'meta_key' => 'closed',
    'meta_value' => 1,
    'post_type' => 'project',
    'order' => 'DESC',
    'orderby' => 'id',
    'author' => $uid,
    'posts_per_page' => $post_per_page,
    'paged' => $query_vars['paged']
);

query_posts($arg);

if(have_posts()) :
    while ( have_posts() ) : the_post();

        if($myCondition)
            continue; //skip record here

        the_title();
    endwhile;

    if(function_exists('wp_pagenavi')):
        wp_pagenavi(); endif;

endif;

Thanks for help.

My condition:

$bids = "select * from ".$wpdb->prefix."project_bids where pid='".get_the_ID()."' and winner='1' order by id DESC";
$res  = $wpdb->get_results($bids);

$selected_bid = $wpdb->get_results("select * from " . $wpdb->prefix . "project_escrow where `pid`={$res[0]->pid}");
$selected_bid = $selected_bid[0];



if(!is_null($selected_bid) )
    continue;

标签: wordpress
0条回答
登录 后发表回答