Support » Fixing WordPress » Pagination inside Secondary Loop

  • Hello everyone!

    I’m trying to get this pagination up and going inside a template file of my theme, but i can’t get why it’s not working. Here’s the page’s code:

    <?php
    /*
    Template Name: Post Page
    */
    ?>
    <?php get_header(); ?>
    
    <section class="row" id="main">
    
        <?php if ( have_posts() ) : while( have_posts() ): the_post(); ?>        
    
            <?php if ( has_post_thumbnail() ) {?>
    
                <section class="row" id="banner">
    
                    <div class="col-md-12 col-lg-12 hidden-xs" id="banner-container">
    
                        <?php the_post_thumbnail('full');?>
    
                    </div>
    
                </section>
    
            <?php } ?>
    
            <section class="row" id="post-content">
                <?php
                $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
                $args = array(
                        'order' => 'DESC',
                        'showposts' => '5',
                        'paged' => $paged
                    );
                ?>
                <?php $latest = new WP_Query($args); ?>
    
                <?php $count = 0; ?>
    
                <?php while( $latest->have_posts() ) : $latest->the_post(); ?>
    
                <?php $count++; ?>
    
                <?php
                    if ($count % 2 == 0) {
    
                        ?> 
    
                            <div class="col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2" id="single-post">
                                <div class="col-xs-12 col-sm-6 col-md-5 col-lg-5" id="post-image">
                                    <div class="col-xs-12 col-sm-12 col-md-10 col-lg-10col-md-offset-1 col-lg-offset-1">
                                        <?php the_post_thumbnail('medium'); ?>
                                    </div>
                                </div>
                                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6" id="post-content">
                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="post-title">
                                        <?php the_title(); ?>
                                    </div>
                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="post-text">
                                        <?php the_content(); ?>
                                    </div>
                                </div>
                            </div>
    
                        <?
    
                    } else {
    
                        ?> 
    
                            <div class="col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2" id="single-post">
                                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6" id="post-content">
                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="post-title">
                                        <?php the_title(); ?>
                                    </div>
                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="post-text">
                                        <?php the_content(); ?>
                                    </div>
                                </div>
                                <div class="col-xs-12 col-sm-6 col-md-5 col-lg-5" id="post-image">
                                    <div class="col-xs-12 col-sm-12 col-md-10 col-lg-10col-md-offset-1 col-lg-offset-1">
                                        <?php the_post_thumbnail('medium'); ?>
                                    </div>
                                </div>
                            </div>
    
                        <?php
    
                    }
    
                ?>
    
                <?php endwhile; ?>
    
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="paginaton-container">
                        <div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
                        <div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>
                    </div>
    
            </section>
    
        <?php endwhile; else:?>
    
        <?php endif;?>
    
    </section>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Any ideas?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Pagination inside Secondary Loop’ is closed to new replies.