• Resolved 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; ?>

    AND my

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Mike M. a11n

    (@mikedmoore)

    Automattic Happiness Engineer

    Hi there,

    This doesn’t appear to be related to WooCommerce. In the future you might have better luck in the WordPress core support forums.

    WP_Query accepts an offset parameter for skipping over posts. You can add the following to your query args:

    
    'offset' => 1,

    This will skip over the latest post in your new query.

    Thread Starter Lionell

    (@underwaterpeoples)

    Oh shoot I’m sorry, thanks for catching that Mike. I just posted this in the WordPress core support forums.

    Plugin Support slash1andy

    (@slash1andy)

    Automattic Happiness Engineer

    Closing, as it’s more of a WordPress core issue.

Viewing 3 replies - 1 through 3 (of 3 total)

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