0
votes

The pagination for this wordpress theme I am coding, don't seem to be working, any one with a better ideal? thank you in advance.

Below is my full code, I am kind of confused, had tried using a plugin and calling out the shortcode wp-pagenavi but its not working either, I would appreciate any help.

<?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array('post_type' => 'post', 'posts_per_page' => 10, 'paged' => $paged);
    $query = new WP_Query($args);
    if( $query->have_posts() ) :
    while( $query->have_posts() ) : $query->the_post(); ?>
    <div class="media">
    <div class="media-left">
    <div class="hovereffect">


        <a href="#"><?php the_post_thumbnail();?></a>
        <div class="overlay">
            <h2>Share</h2>
            <p class="icon-links">
                <a href="#">
                    <span class="fa fa-twitter"></span>
                </a>
                <a href="#">
                    <span class="fa fa-facebook"></span>
                </a>
                <a href="#">
                    <span class="fa fa-instagram"></span>
                </a>
            </p>
        </div>

    </div>
    </div>
     <div class="media-body">
        <h4 class="media-heading"><?php the_title()?></h4>
        <p class="media-author"><b><?php the_author()?></b> - <?php echo get_the_date(); ?></p>
            <?php the_content();?>
        </div>
    </div>
    <?php endwhile;?>
<!-- pagination -->
<?php next_posts_link(); ?>
<?php previous_posts_link(); ?>
<?php else : ?>
<!-- No posts found -->
<?php endif; ?>
1

1 Answers

0
votes

You have to use $query->max_num_pages in the second parameter of next_posts_link as you can see here

// next_posts_link() usage with max_num_pages
next_posts_link( 'Older Entries', $the_query->max_num_pages );
previous_posts_link( 'Newer Entries' );