Title: get_posts offset not working
Last modified: April 10, 2017

---

# get_posts offset not working

 *  [mike62](https://wordpress.org/support/users/mike62/)
 * (@mike62)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/get_posts-offset-not-working/)
 * I am customizing the archive.php to display a large version of the first post,
   then list the rest of the posts in boxes. It’s working great, except the offset
   for the second get_posts() is not working. It is including the first post, and
   I can’t figure out why; I’ve never had this happen before. Here is the code for
   my archive.php:
 *     ```
       <?php
       /**
        * The template for displaying archive pages.
        *
        * @link https://codex.wordpress.org/Template_Hierarchy
        *
        * @package The_Acorn_House
        */
   
       get_header(); ?>
   
       	<div id="primary" class="content-area">
       		<main id="main" class="site-main" role="main">
       			<div class="container">
       				<div class="container-inner">
   
   
       						<?php 
       						$metaValue = wp_get_terms_meta($cat, 'category_image' ,true); 
       						if ($metaValue){
       							echo '<div class="featured-image"><img src="';
       							echo $metaValue;
       							echo '" /></div><!-- .featured-image -->';
       						}?>
   
   
       						<div class="item-box title-box category-title">
       							<div class="item-box-inner">
       								<h2>Category</h2>
       								<?php if (category_description())
       								{
       									echo category_description();
       								} else {
       									echo '<h3>';
       									single_cat_title();
       									echo '</h3>';
       								}
       								?>
       							</div><!-- .item-box-inner -->
       						</div><!-- .item-box -->
       				</div><!--.container-inner -->
       			</div><!--.container -->
   
   
       			<?php   // show 3 posts from each subcategory
   
       				$categories = get_categories( array(
       				    'orderby' => 'name',
       				    'parent'  => $cat
       				) );
   
       				if ($categories){
   
       				foreach ( $categories as $category ) {?>
   
       				    <div class="container alternaterow blog-subcategory">
       						<div class="container-inner">
       							<?php 
       								echo '<h3><a href="';
       								echo $category->slug;
       								echo '">';
       								echo $category->name;
       								echo '</a></h3>'; ?>
   
       							<div class="thirdcol-container">	
       								<?php $args = array(
       									'posts_per_page'   => 3,
       									'category'         => $category->term_id,
       									'orderby'          => 'post_date',
       									'order'            => 'DESC',
       									'post_type'        => 'post',
       									'post_status'      => 'publish'
       									 );
   
       								$myposts = get_posts( $args );
       								foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
       									<div class="thirdcol">
       										<div class="blog-excerpt blog-small item-box">
       											<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('medium-landscape'); ?></a>
       											<?php include(STYLESHEETPATH . '/inc/item-box-inner.php'); ?>
       										</div><!-- .blog-excerpt -->
       									</div><!-- .thirdcol -->
       								<?php endforeach; 
       								wp_reset_postdata();?>
       							</div><!-- .thirdcol-container -->
       						</div><!--.container-inner -->
       					</div><!--.container -->
   
       				<?php }
       				} ?>
   
       						<!-- show first post, larger -->
       						<div class="container-inner cat-top-post">
       							<?php $args = array(
       								'posts_per_page'   => 1,
       								'category'         => $cat,
       								'orderby'          => 'post_date',
       								'order'            => 'DESC',
       								'post_type'        => 'post',
       								'post_status'      => 'publish'
       								 );
   
       							$myposts = get_posts( $args );
       							foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
       								<div class="featured-image column">
       									<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('large'); ?></a>
       								</div><!-- .featured-image -->
   
       								<div class="blog-excerpt item-box column">
       									<?php include(STYLESHEETPATH . '/inc/item-box-inner.php'); ?>
       								</div><!-- .blog-excerpt -->
   
       							<?php endforeach; 
       							wp_reset_postdata();?>	
   
       						</div><!-- .container-inner -->
   
       					<div class="container category-list-posts">
       						<div class="container-inner">
       							<div class="thirdcol-container">
       						<?php $args = array(
       								'posts_per_page'   => -1,
       								'offset'           => 1,
       								'category'         => $cat,
       								'orderby'          => 'post_date',
       								'order'            => 'DESC',
       								'post_type'        => 'post',
       								'post_status'      => 'publish'
       								 );
   
       							$myposts = get_posts( $args );
       							foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
       							<!-- show all the rest of the posts, smaller -->
   
       							<div class="thirdcol">
       								<div class="blog-excerpt blog-small item-box">
       									<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('medium-landscape'); ?></a>
       									<?php include(STYLESHEETPATH . '/inc/item-box-inner.php'); ?>
       								</div><!-- .blog-excerpt -->
       							</div><!-- .thirdcol -->
   
       							<?php endforeach; 
       							wp_reset_postdata();
   
       							//the_posts_navigation();
   
       						?>
       							</div><!-- .thirdcol-container -->
       						</div><!--.container-inner -->
       					</div><!--.container -->
   
       		</main><!-- #main -->
       	</div><!-- #primary -->
   
       <?php
       get_footer();
       ?>
       ```
   
    -  This topic was modified 9 years, 1 month ago by [mike62](https://wordpress.org/support/users/mike62/).

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/get_posts-offset-not-working/#post-9016259)
 * [https://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters](https://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters)
 * > posts_per_page (int) – number of post to show per page (available since Version
   > 2.1, replaced showposts parameter). Use ‘posts_per_page’=>-1 to show all posts(
   > the ‘offset’ parameter is ignored with a -1 value).
 *  Thread Starter [mike62](https://wordpress.org/support/users/mike62/)
 * (@mike62)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/get_posts-offset-not-working/#post-9016512)
 * aHA! Thanks!! Sorry for not finding that myself… :S

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

The topic ‘get_posts offset not working’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [mike62](https://wordpress.org/support/users/mike62/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/get_posts-offset-not-working/#post-9016512)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
