WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Pagination for custom query w/ 2 CPTs (2 posts)

  1. bradstemke
    Member
    Posted 1 year ago #

    I have been racking my brain and google to try and solve this issue I seem to be having for 2 days. I have never posted here, so I figured I would give it a try.

    Basically, I have a wp_query I built that includes posts from 2 different custom post types. Right now my page will show the most recent 6 posts, pulling from both post types. But I can't seem to get the pagination working, to continue with the links at the bottom to pull in the next series of 6 posts. I am assuming it is an issue with pulling in 2 custom post types, as I have another page that this works fine on.

    <?php
                      $temp = $wp_query;
                      $wp_query = null;
                      $wp_query = new WP_Query(); 
    
                      $wp_query->query( array(
                        'post_type' => array( 'share', 'article' ),
                        'post_per_page' => '6',
                        'paged' => $paged,
                    ) );
    
                    while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
                    <div <?php post_class('feed-item span4'); ?> />
                      <div class='content'>
                        <?php getImage('1'); ?>
                        <span class="label"><?php foreach((get_the_category()) as $category) {
                          echo $category->cat_name . ' ';
                        } ?>
                        </span>
    
                        <?php single_cat_title(); ?>
                        <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><h5><?php the_title(); ?></h5></a>
                        <?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,25); echo '...' ?>
                      </div>
                    </div>
    
                  <?php endwhile; ?>
    
                  </div> <!-- .row -->
                </div> <!-- Blog/Share Archive Feed -->    
    
                <?php include ('sidebar-home.php'); ?>
    
            <div class="span12 showmemore navigation">
              <?php previous_posts_link('&laquo; Previous Entries', '1000') ?>
              <?php next_posts_link('Next Entries &laquo;', '1000') ?>
            </div>
    
            <?php
              $wp_query = null;
              $wp_query = $temp;  // Reset
            ?>
  2. bradstemke
    Member
    Posted 1 year ago #

    nevermind. got it

Topic Closed

This topic has been closed to new replies.

About this Topic