-1

this question was asked for many times, but i still unable to fix it. Here is my code

<?php get_header(); ?>

<?php   $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
    $custom_args = array(
    'post_type' => 'post',
    'meta_key' => 'views_daily',
    'orderby' => 'meta_value_num',
    'order' => 'DESC',
    'posts_per_page' => 15,
        'paged' => $paged
    );

  $custom_query = new WP_Query( $custom_args ); ?>

  <?php if ( $custom_query->have_posts() ) : ?>

    <!-- the loop -->
    <?php while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
            <div class="col3">
                <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
                    <div class="entry">
                        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"></a>
                        <div id="morepage-list"><?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?></div>
<div class="postdata"></div></div></div></div>
            <?php
                $counter++;
                if ($counter % 3 == 0) echo '<div class="cboth"></div>' ;
            ?>
        <?php endwhile; ?>
            <?php wp_pagenavi(); ?>
  <?php else:  ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
  <?php endif; ?>

<?php get_footer(); ?>

I tried some suggestions that i found on web, but nothing helped. It is only showing first 15 results no more. But i want full possible pagination depending on my query details. Sorry for bad language.

  • please post the exact code you are using for the wp_pagenavi() - using the plugin for custom queries is explained in scribu.net/wordpress/wp-pagenavi/wpn-2-74.html – Michael Apr 23 '17 at 23:29
  • I tried it, but it did not go on. – Vladislav Bickov Apr 23 '17 at 23:30
  • please edit your question to post the full code of your template including the wp_pagenavi code. – Michael Apr 23 '17 at 23:32
  • edited and added full code – Vladislav Bickov Apr 23 '17 at 23:36
  • have you tried exactly as @Abdul Awal has written in his answer? – Michael Apr 24 '17 at 0:12
4

You need to change <?php wp_pagenavi(); ?> to the following:

<?php wp_pagenavi( array( 'query' => $custom_query )); ?>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.