Introduction
WordPress is a popular tool for creating websites. Sometimes, you need to hide the latest post. This guide will show you how to do that.
Why Exclude the Latest Post?
There are many reasons for hiding the latest post. You might want to feature it somewhere else on the page. Or, you might want to keep it private for a while. Whatever the reason, this guide will help.
What is the WordPress Post Loop?
The WordPress post loop shows your posts on the website. It lists posts in order, with the newest post at the top.
Steps to Exclude the Latest Post
1. Open Your Theme’s Functions File
First, you need to open your theme’s functions.php file. This file controls how your theme works.
2. Add The Code
Next, add the following code to the functions.php file. This code will exclude the latest post:
function exclude_latest_post($query) {
if ($query->is_home() && $query->is_main_query()) {
$query->set('offset', 1);
}
}
add_action('pre_get_posts', 'exclude_latest_post');
This code tells WordPress to skip the latest post on the homepage.
3. Save The File
After adding the code, save the functions.php file. Now, the latest post will not show in the post loop.

Credit: forum.blocsapp.com

Credit: www.wpbeginner.com
Check Your Work
After saving the file, check your website. The latest post should not appear in the post loop. If it does, check the code again.
Advanced Options
If you want more control, you can change the code. For example, you can exclude posts by category. This code will exclude posts from a category:
function exclude_category_posts($query) {
if ($query->is_home() && $query->is_main_query()) {
$query->set('cat', '-1'); // Replace -1 with your category ID
}
}
add_action('pre_get_posts', 'exclude_category_posts');
Replace -1 with your category ID. This will exclude posts from that category.
Frequently Asked Questions
How Can I Exclude The Latest Post In WordPress?
Use a custom query in your theme’s functions. php file.
What Code Is Needed To Exclude The Latest Post?
Add `post__not_in` with an array of the latest post ID.
Where Do I Add The Exclusion Code In WordPress?
Place the code in your theme’s functions. php file.
Can I Exclude More Than One Post?
Yes, add more post IDs to the `post__not_in` array.
Conclusion
Excluding the latest post from the WordPress post loop is easy. Just follow the steps in this guide. You can also customize the code to fit your needs. Happy blogging!