• Lionell

    (@underwaterpeoples)


    Hey guys, hoping you can help here. I’ve tried several things but nothing seems to work…

    So as you can see from my link, theres a top header showing the latest post and the bottom part should show the rest, but its displaying the latest post again.
    I’ve inputed a <?php wp_reset_query(); ?> so the top doesn’t conflict with the bottom half. The top half works perfectly tho.

    Here is my code for the bottom half:

    <?php
    $paged = ( get_query_var( 'paged' ) ) ? 
    get_query_var( 'paged' ) : 1;
    $args = array(
      'posts_per_page' => 10,
      'cat' => '3,4',
      'paged' => $paged
     );
    	$custom_query = new WP_Query( $args );?>
    	<?php if ( $custom_query->have_posts() ) : ?>
    	<?php while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
    	
    	<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );?>
    
         <?php $class = (empty($class) ? 'class="alternate"' : '');?>
    		<div id="bios-posts-single" <?php echo $class; ?>>
    		     <a href="<?php the_permalink(); ?>">
    		     <img class="hidden" src="<?php echo $backgroundImg[0]; ?>">
    		     <div class="bios-post-info">
    		     <small>Bio: By <?php the_author(); ?></small>
    		     <h1 class="bios-post-h1"><?php the_title(); ?></h1>
    		 <? echo '<p class="post-excerpt">' . get_the_excerpt() . '</p>'; ?>
    		     			<?php the_date('m-d-Y', '<h2>', '</h2>'); ?>
    		   </div>
    		    <div class="bios-post-img">
    		    <img class="shown" src="<?php echo $backgroundImg[0]; ?>">
    		    </div>
    		     </a>
    		</div>
    		 <?php endwhile; ?>
    		
    <div class="pagination">
    <?php echo paginate_links( array(
      'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
      'total'        => $custom_query->max_num_pages,
      'current'      => max( 1, get_query_var( 'paged' ) ),
      'format'       => '?paged=%#%',
      'show_all'     => false,
      'type'         => 'plain',
      'end_size'     => 2,
      'mid_size'     => 1,
      'prev_next'    => true,
      'prev_text'    => sprintf( '<i></i> %1$s', __( '<', 'text-domain' ) ),
      'next_text'    => sprintf( '%1$s <i></i>', __( '>', 'text-domain' ) ),
      'add_args'     => false,
      'add_fragment' => '',
       ) );
    ?>
    </div>
    <?php wp_reset_postdata();?>
    				
    				<?php else : ?>
    				    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    				<?php endif; ?>
    • This topic was modified 8 years ago by Lionell.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • hyperionstudios

    (@hyperionstudios)

    Hi Lionell, I see that wp_reset_postdata() is entered for the bottom half but have you entered wp_reset_postdata() at the end of the header query?
    the way I see it
    header query
    wp_reset_postdata()
    footer query

Viewing 1 replies (of 1 total)

The topic ‘Offset with pagination on custom query’ is closed to new replies.