Loop offset by 1
-
I have a page , News Page, that has a featured article on top, with all other articles(posts) displayed below. The featured article and the first article below are the same. I need the first article below to be offset by 1 so the featured article is not displayed twice. I have tried a query to offset by 1, but the following pages display the same articles as the first page.
My Code:
<?php /* Template Name: News Page */ get_header(); ?> <div class="container"> <div class="row"> <h2 class="page_title">Our Latest News</h2> <hr class="fade_rule"> </div> </div> <div class="container"> <div class="row"> </div> <!--#######################################################################################--> <?php if( !is_paged() ) {?> <div class="news_main news_feed"> <?php $the_query = new WP_Query( 'showposts=1' ); ?> <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> <a href="<?php the_permalink(); ?>"> <div class="news_feature_thumb"> <?php if ( has_post_thumbnail() ) the_post_thumbnail( 'full' ); else ?> </div> <div class="news_featured_content"> <h3 class="feature-title"> <?php the_title(); ?> </h3> <p class="news_date">Date posted: <?php the_date(); ?> </p> <?php echo get_news_excerpt(); ?> </div> <div class="clear"></div> </a> </div> <?php endwhile;?> <br /> <?php } else ?> <!--#######################################################################################--> <div id="content" class="js-masonry" data-masonry-options='{ "itemSelector": ".news_item" }'> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="col-4 news_feed_element news_feed news_item"> <a href="<?php the_permalink(); ?>"> <div class="news_post_thumb"> <?php if ( has_post_thumbnail() ) the_post_thumbnail( 'full' ); else ?> </div> <div class="news_feed_content"> <h3 class="feature-title"> <?php the_title(); ?> </h3> <p class="news_date">Date posted: <?php the_date(); ?> </p> <?php echo get_news_excerpt(); ?> </div> <div class="clear"></div> </a> </div> <?php endwhile;?> </div> <div class="clear"></div> </div> <div class="navigation" style="width: 100%; text-align:center; margin:0 auto;"> <p> <?php posts_nav_link(); ?> </p> </div> <?php else : ?> <h2>Not Found</h2> <?php endif; ?> </div> <?php get_footer(); ?>
Any suggestions will be welcomed.
Thank you
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Loop offset by 1’ is closed to new replies.