• Hello WordPress Community.

    I am coding my first wordpress theme and have made great strides with a lot of help from the codex and various posts on the forums, but I have hit a bit of a snag setting up pagination on the homepage of my blog. It is currently set up using a WP_Query to include three custom post types and showing the right posts in the right order, but I have had difficulties applying any sort of pagination. This includes plug-ins like wp-navi and some other methods I have seen on the forums. All methods that I have used have resulted in my URL showing I am on page 2 of the posts, but still showing the home page post set.

    This is my base code without any of the navigation methods I have tried:

    <div class="col-md-8 homePostContainer">
    
                <?php
                  $args = array (
                    "posts_per_page" => 3,
                    "post_type" => array("movie-review", "video-game-review", "tv-review", "post"),
                    'category__not_in' => 3,
                  );
                  $wp_query = new WP_Query($args);
    
                  if($wp_query->have_posts()) :
                    while($wp_query->have_posts()) :
                      $wp_query->the_post();
                ?>
    
                  <article>
                    <div class="homePost">
                      <?php  $post_background = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ); ?>
                      <div class="hpImage" style="background-image: url(<?php echo $post_background['0'];?>)">
                      </div>
                      <div class="hpContent">
                        <?php if (in_category('movies')) { ?>
                        <img class="hpIcon" src="http://localhost:8888/bootstrap_to_wp/wp-content/uploads/2015/05/Movies.png" alt="Movies">
    
                        <?php } elseif (in_category('video-games')) { ?>
                        <img class="hpIcon" src="http://localhost:8888/bootstrap_to_wp/wp-content/uploads/2015/05/Games.png" alt="Games">
    
                        <?php } elseif (in_category('television')) { ?>
                        <img class="hpIcon" src="http://localhost:8888/bootstrap_to_wp/wp-content/uploads/2015/05/Television.png" alt="Television">
    
                        <?php } else { ?>
                        <img class="hpIcon" src="http://kokenvoormijndochter.nl/wp-content/themes/twentyten-koken/images/v.png">
    
                        <?php } ?>
                        <div class="hpDetails">
                          <?php the_author(); ?>  |  <?php echo the_time('l, F jS, Y'); ?>
                        </div>
                        <h2 class="hpHead"><?php the_title();?></h2>
                        <h3 class="hpSubhead"><?php the_excerpt(); ?></h3>
                      </div>
                    </div>
                  </article>
                <?php endwhile; ?>
                <?php wp_reset_postdata(); ?>
                <?php endif; ?>
    
              </div>

    If anyone can direct me to a solution or help me out I would greatly appreciate it.

    Also, if you need me to post any further code, I can do that as well.

    Thanks in advance!

  • The topic ‘Homepage Pagination using WP_Query’ is closed to new replies.