You shouldn’t really need to “exclude” anything. Just make use of the built in loop tracking. WP_Query
will “remember” where you left off. For example:
if (have_posts()) {
while (have_posts()) {
the_post();
echo 'firstpost##';
the_content();
echo '##endfirstpost';
break;
}
}
// do some other stuff
if (have_posts()) {
while (have_posts()) {
the_post();
echo 'otherposts##';
the_content();
echo '##endotherposts';
break;
}
}
Or just roll the code into the same loop:
if (have_posts()) {
while (have_posts()) {
the_post();
if (0 == $wp_query->current_post) {
echo 'firstpost##';
else {
echo 'otherposts##';
}
the_content();
if (0 == $wp_query->current_post) {
echo '##endfirstpost';
else {
echo '##endotherposts';
}
break;
}
}
Related Posts:
- 3 Posts in Loop, Show Stickies First
- Is `query_posts` really slower than secondary query?
- Are there any scenarios where the query_posts may be used?
- Why is it necessary to call rewind_posts() when using the loop more than once? [duplicate]
- Apply styling only to first page sticky posts
- Multiple posts with one loop iteration
- Post Loop not Returning Permalink
- How to Loop within a Loop (Display Children and then Grandchildren)
- Exclude first 2 posts with meta_key from loop
- How to retrieve “sticky” post outside the “loop”?
- Better way to display posts from specific categories, in a grid layout
- popular post weekly and monthly
- Move sticky posts down in main loop
- sticky post in custom loop
- Query last updated posts (posts updated in the last 24 hours)
- Displaying terms based on loop posts?
- Duplicated posts on category page
- Make blog page show 10 on first page, 9 on every other page
- Blog page Server error 500 with stick post loop in query.php
- How to display posts by vote count and if no value continue with latest posts with no votes?
- Showing sticky posts with get_posts()
- query_posts() vs get_posts() multiple loops [duplicate]
- Custom loops, sticky posts, and pagination nightmare
- Exclude duplicated $sticky post from combined loop content
- How to order by multiple fields using standard query_posts?
- Loop for sticky posts
- Pagination not working in category listing [duplicate]
- How can I improve the performance of this query_posts loop?
- Adding div after every two post on main loop! Why will first post not get counted?
- How can I access specific posts brought back by query_posts?
- Separate First Post Loop
- Query posts only with actual text content (not including shortcode or images)
- query_posts clarification needed
- Exclude current post ID from loop in sidepbar.php
- Why does my WP_Query pagination on a custom page.php only loads the homepage?
- Get a Post Loop based on Logged in User information into a Shortcode
- Custom Query with Sticky Posts
- how to add 4 post in one carousel slide
- Insert/sticky multiple posts in multiple positions
- Query counting excluded category on paged loop
- get_posts and wp_autop (remove filter)
- query_posts ignores the argument
- The Loop isn’t working
- Twitter bootstrap carousel multiple items in carousel
- show posts from one category with comments only
- Least Number of Loops to Create Custom Homepage?
- Multiple loops with / without sticky posts and different post limits
- Different style for first two (sticky) posts
- How to do query_posts on tags pages
- Limitless amount of posts in custom archive page
- I make sticky post for my archive page for custom post type with ACF field and loop is not working
- How to split a loop into multiple columns
- Using the Loop to show all levels of subpages under a parent page? Halfway there
- Cleanest Way to Select Every Second Element in a Loop?
- Get post by page name or slug
- save_post + insert_post = infinite loop
- ACF Repeater loops and resets – where is the reset_rows() documentation? [closed]
- Why do themes have `while( have_posts() )` in templates like single.php?
- What is best way passing variables to theme templates and using them different places like widgets?
- pop-up lighbox with AJAX
- Load comments per post on click with AJAX
- WordPress Loop – Style rows of posts differently
- taxonomy tags 404 to custom post types
- A smarter way to display multiple loops inside a page template
- How to print out menu names in the foreach loop?
- How do I style the first two posts of a loop
- How to get the role id from the role name?
- How do I paginate a get_posts() request inside another page loop (Paginating childpages)
- How to remove a plugin filter’s priority on specific loops (custom queries)?
- How to provide meta_key array to wp_query?
- How to stop the continuation of posts on the second loop from where the first ended
- Show articles in Pair
- Make a loop to return x number of posts, but only if they have content or excerpt
- Closing the loop…featured image variable based on post id
- How do you stop the rendering of the website to have something display on the front-end?
- add_action in the loop hooks
- How to render the single post template with the post name?
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Offset Loop by 1 , Limit next loop to 1 (Most Recent) Post
- Custom template for password protected page
- Category sticky latest
- How to show multiple attachements together with Scribu’s Posts 2 Posts connector?
- Script that gets the first tag of post and query all other posts with the same tag
- Database query and get_user_meta return incorrect data
- Need to while loop and display contents in the subfield of a group field given by ACF
- How to display a loop of custom post types in columns
- dispaly all hierarchical post types from a taxonomy
- WordPress Modal showing posts not working properly
- Query posts and display all dates in repeater field in chronological order
- Multiple loops in set intervals with code in between
- Attachment Metadata inside of Loop
- Template included with plugin doesn’t return all posts for custom taxonomy
- Adding pagination to WP_Query [duplicate]
- Stuck with conflicting loops on page template
- Multiple loop for “featured” items returns wrong posts
- How to get current page id and compare it to looped pages inside the same page?
- Show amount of posts created today above loop?
- How to create WordPress loop with combination of 4 and 2 columns twitter-bootstrap?
- posts_nav_link() not working on index.php
- How to add custom HTML markup and classes to the_content()?