Support » Plugin: WP-PageNavi » Not working with query with custom field

  • Hi!

    In category.php, I’ve got a query:

    <?php
      $idcategoria = get_query_var('cat');
      $array1 = new WP_Query(array('cat'=> $idcategoria, 'fields'=> 'ids','meta_key' => 'premium', 'meta_value' => '1','orderby' => 'rand'));
      $array2 = new WP_Query(array('cat'=> $idcategoria, 'fields'=> 'ids', 'meta_key' => 'premium', 'meta_value' => '0','orderby' => 'rand'));
      $ids = array_merge($array1->posts, $array2->posts);
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
      $result = new WP_Query(array('post__in' => $ids,'orderby' => 'post__in','posts_per_page'=>10,'paged' => $paged,));
    ?>
    <?php if( $result->have_posts() ): while( $result->have_posts() ): $result->the_post();?>          ... content....
    <?php endwhile; endif; ?>
    <div id="pagination">
      <?php if(function_exists('wp_pagenavi')) :  wp_pagenavi(array( 'query' => $result ));  endif; wp_reset_query();?>
    </div>

    When shows results from category with ‘premium’ custom field everything works perfect, but when is any other category wp-pagnavi is not showing.

    Any ideas?

    Thank you!

    https://wordpress.org/plugins/wp-pagenavi/

  • The topic ‘Not working with query with custom field’ is closed to new replies.