Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter xrayeye

    (@xrayeye)

    Hi alchymyth,

    Thanks so much for your reply. That helped as the pagination is now showing, but it’s stuck always on the first page.

    This how my code is looking right now:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $temp = $featured; // assign ordinal query to temp variable for later use
    $featured = null;
    $featured = new WP_Query(array( 'post_type' => 'projects','category__in'=> 14, 'post_status' => 'publish', 'posts_per_page' => 2, 'paged' => $paged)); ?>
    
    if ( $featured->have_posts() ) while ( $featured->have_posts()) : $featured->the_post();
    
    <div id="content">
    </div>
    
     <?php endwhile; ?>
     <?php wp_reset_postdata(); // reset the query ?>  
    
    <div class="pagination">
    <span class="pag-next"><?php next_posts_link('Older Entries »', $featured->max_num_pages); ?> </span>
    <span class="pag-previous"><?php previous_posts_link('Newer Entries', $featured->max_num_pages); ?></span>
    </div> 
    
    $temp = $featured; // assign ordinal query to temp variable for later use
    $featured = null;

    Maybe it has something to do with the way I’m running the loop on other pages. There’s a projects page where I’m displaying thumbnails of all the project posts like this:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    <?php $projects_query = new WP_Query(array( 'post_type' => 'projects','post_status' => 'publish', 'posts_per_page' => 9, 'paged' => $paged));
    while($projects_query->have_posts()) : $projects_query->the_post(); ?>
        <div id="content">
    
        </div>
    <?php endwhile; ?>
    <?php wp_reset_postdata(); // reset the query ?>  
    
    <div class="pagination">
        <span class="pag-next"><?php next_posts_link(); ?> </span>
        <span class="pag-previous"><?php previous_posts_link(); ?></span>
    </div>

    And the blog page where I display regular posts looks like this:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $temp = $journal; // assign ordinal query to temp variable for later use
    $journal = null;
    $journal = new WP_Query(array( 'post_type' => 'post','post_status' => 'publish', 'posts_per_page' => 3,'paged' => $paged ));
    
    if ( have_posts() ) while ( have_posts() ) : the_post(); 
    
    <div id="content">
    </div>
    
    <?php endwhile; // end of the loop. ?>
    <?php wp_reset_postdata(); // reset the query ?>  
    
    <div class="pagination">
        <span class="pag-next"><?php next_posts_link(); ?> </span>
        <span class="pag-previous"><?php previous_posts_link(); ?></span>
    </div>

    I’m really lost here. I can’t pin down what’s the mistake I’m making!

Viewing 1 replies (of 1 total)