treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Wordpress query_post loop pagination problems.

  • Hey all,

    I'm running into difficulties trying to get query_posts to paginate.

    Basically I'm attempting to output only posts that match a tag (on the homepage, tag of "front-page") or category for the other pages.

    Here is what I have so far;

                  <?php
              if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
              elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
              else { $paged = 1; }
              query_posts( array ( 'tag' => 'front-page', 'posts_per_page' => 5, 'paged' => $paged ) ); ?>
                  <?php if ( have_posts() ): while ( have_posts() ) : the_post(); ?>
    
                      <article class="excerpt category-<?php $category = get_the_category(); echo $category[0]->slug; ?>">
                          <h2><a href="<?php esc_url( the_permalink() ); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                          <span class="date" datetime="<?php the_time( 'Y-m-d' ); ?>"><?php echo get_the_date('F jS, Y'); ?></span>
    
                          <?php the_field('excerpt'); ?>
    
                          <a href="<?php esc_url( the_permalink() ); ?>" title="<?php the_title(); ?>" class="button blue">Read More...</a>
                          <a class="comment-count" href="<?php esc_url( the_permalink() ); ?>#disqus_thread"></a>
                      </article>
    
                  <?php endwhile; ?>
    
                  <?php else: ?>
                      <p class="nothing-found">Nothing Here, Son!</p>
                  <?php endif; ?>
              <?php wp_reset_query(); ?>
    

    Any ideas on how I can paginate the above? I've tried all sorts of variations but are working properly.