sale-bubble sign-up-large

30% Savings on all Shared Hosting packages and billing cycles
Offer is valid for any shared hosting package & billing cycle including 1, 2 and 3 year accounts. Offer is limited to 1 per customer, is a one-time discount and for new accounts only. To take advantage of the offer use PROMO CODE: SAVE30 when placing your order.

How to Exclude Latest Post from the WordPress Post Loop

Blog - WordPress


Excluding latest posts from the loop and/or offset posts in the loop is one of the things that comes in handy when editing or designing themes. In this article we will show you how you can use the offset parameter in wp_query function to exclude latest posts from the WordPress post loop.

First you will need to find the loop that you are working with. Then you will need to add the following parameter:

query_posts('posts_per_page=5&offset=1');

This query is telling the loop to only display 5 posts which follow the most recent post (1). The important part in this code is “offset” and this magic word is doing the whole thing.

Your loop code should look like:

<?php
query_posts('posts_per_page=6&offset=1');
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>

This should be it. If you have any questions feel free to ask via comments.

Source: WP Codex

How to Exclude Latest Post from the WordPress Post Loop is a post from: WPBeginner which is not allowed to be copied on other sites.

Related posts:

  1. How to Exclude Sticky Posts from the Loop in WordPress
  2. How to Display Any Number of Posts in a WordPress Loop
  3. How to Display the Latest Sticky Posts in WordPress


(read full article on source site)

busy



Disclosure: Content posted to this site is in no way an endorsement for a product or service and may result in compensation from the vendor. Some content contained in this site is syndicated content.