How to Hide Posts on Your WordPress Homepage
Most WordPress themes are set up so that your latest blog posts appear on the front page of your site. Or, if you have a static homepage, your newest entries appear on a dedicated page. Regardless of how these posts are displayed – in a list, in a tiled view, or what have you – one thing remains the same: the newest posts appear first.
But what if you don’t want your newest blog post to have such a prominent position? Believe it or not, this is actually a fairly common desire from bloggers in every industry. Let’s take some time now to explore some reasons why bloggers want to hide posts in the first place and how to accomplish this task quickly and easily.
Why Hide Posts?
There are a number of reasons why someone would want to hide a post from his or her homepage. For starters, your blog might offer a variety of types of posts from brief news pieces to more in-depth tutorials. The latter make for more appealing posts to appear on a homepage because they are always valuable and not time-sensitive. Plus, if you don’t update your blog super frequently, emphasizing your high value content over news makes your site more relevant on a consistent basis.
Maybe you’ve recently written a post on a controversial topic and don’t want that to be the first thing your visitors see. This is understandable as you wouldn’t want to detract from other, perhaps more relevant, posts. Or maybe you only want to feature posts written by you and not guest bloggers. Or maybe you only want posts from a certain category to appear. The reasons are diverse. What’s important is you can make this simple change pretty painlessly. And you have a couple of options to get it done.
Consider Creating Pages
This requires some planning ahead of time but it’s by far the simplest method to prevent certain posts from appearing on your blog’s homepage – don’t make it a post at all.
Instead, create a new page and post your content there. You can then select where you want this page to appear. You can opt to not have a link on the homepage to this page if you’d like by modifying your menus. Just don’t list the page in the menu as a link and all should be fine. Quick and painless.
Again, this only works if the content in question hasn’t been created yet and you don’t anticipate needing to do this very often. Still, it’s an easy fix.
Use WP Hide Post Plugin
The easiest way to exclude posts from the homepage is of course using a plugin (if your homepage is setup to display latest posts). One free option is the WP Hide Post plugin. With this installed you can hide posts (from any post types) from select pages. The plugin is simple and straightforward.
Once installed, you’re provided with a number of options in terms of post visibility right from within the post editor:
You can opt to remove the post from your site’s homepage. You can also remove it from applicable category pages, tag pages and archive pages. You can even select the option to prevent a specific post from appearing in site-wide search results as well as on dedicated author pages. It’s up to you.
You can hide the post in question in all of these ways or just from the homepage. In every other place you don’t select, the post will appear as normal with normal linking structure and everything. That is, it will still have a standard permalink and will be included in the sitemap. This means it’s still searchable via search engines and will appear in those results but it won’t appear at the top of your site. This can also be helpful when you’re creating exclusive content for your readers and you plan on only providing access to it by means of a direct link.
As a side note, this plugin can be used to hide posts on any of your custom post types as well. You just have to enable WP Hide Post’s visibility settings under Settings > Hide Posts in the main WordPress menu.
Hiding Posts from RSS Feeds
WP Hide Post can be used to hide posts from showing up as published in your RSS feed as well.
Again, you may wish to do this if your intent is to create posts that act as resources that don’t fit in with your blog’s main style or focus (but you’d still like to rank for in terms of SEO) or if you write posts on occasion that are off-topic and don’t want available to readers as the first thing they see when visiting your site.
To do this, all you have to do is check the box that says “Hide Feeds” on the righthand side of the post editor once the plugin is installed.
Manually Hiding Categories
If you want to hide an entire category from your homepage, you can do this using the WP Hide Post plugin discussed above or you can manually add a bit of code into your child theme functions.php file or via the popular Code Snippets plugin.
Basically, you create a dedicated category for the posts you want to hide, jot down the category ID (you can edit a category and look at the URL to locate the ID), then paste the following bit of code at the end of the file right before “?>” and replace the “xx” with the category ID:
function myprefix_exclude_category($query) {
if ( ! is_admin() && $query->is_main_query() && $query->is_home() ) {
$query->set( 'cat', '-xx' );
}
return $query;
}
add_filter( 'pre_get_posts', 'myprefix_exclude_category' );
This bit of code will prevent your chosen category from showing up on your site’s homepage, which can be useful if you plan on offering multiple channels of content on a regular basis and don’t want one of them mixed up with your site’s main content.
With the ability to hide certain posts from your WordPress site’s homepage in your developer’s tool belt, you gain the freedom to create more of the posts you want to make without cluttering up your site. You no longer have to fear making a commentary on a hot subject or creating more content with SEO in mind, since your homepage will remain exactly as you want it to.
Do you hide certain posts from your site’s homepage? If so, why? Also, what tools do you use to accomplish this? We’d love to hear your feedback.
Thank you very much for the exciting post. I was exactly looking for this. However, I tried a few methods but didn’t work. But this time it works. So thanks a lot.
You’re welcome Abrar 🙂
Really useful- just what I am looking for after installing a slider using posts!
Glad you liked it Lisa!
Thank you sir…..
Thanks for the help, Tom! This very effective. We just used WP HidePost on our site. Cheers! 🙂
very good !!! thank you !
Thanks , for helpful information’s .
Hey Tom, Thanks a lot you just saved my Event from the scrapper. I don’t know how a spammer used my feed and published all articles on his site. Google considered my all post copied and penalized me. But after use of this plugin I can focus on my Event 🙂
Thank you very much 🙂
You’re all more than welcome! 🙂
Thanks so much!
I was having problems, but I figured it out:
the second to last apostrophe (the one before ‘exclude_category’) is actually not an apostrophe but a strange symbol. I switched it to an apostrophe and that worked.
One question I had, though, was how do I do this in a child theme? I tried copying the functions.php file into the child directory, but that wouldn’t work. It only worked when I overwrote the original functions.php file in the original theme.
(I’m using Twenty Fifteen; don’t know if that helps)
Thanks for the heads up, I fixed the code 😉
You should create a new blank functions.php file in your child theme. Here is an example child theme I use for my Total WordPress theme so you can see how a child theme should be setup. Basically your child theme should have a functions.php file already (for loading the stylesheet) and you would add this code right under that.
Thanks for the info, I am currently want to hide a category from my blog not to appear on front page
Really Thanks @Tom Ewer:)
What I would like to do for my wife’s site is ideally have all posts on a hidden page, then make a menu that contains categories only. This way she can write posts, but they would only appear automatically on the page related to that category. If that makes sense?
Thanks
I used WP hide post for a long time, but recently realized it was making my site slow. I don’t know why. I’m considering writing my own code, just need to learn a bit of PHP.
Hum, I don’t see why it would slow down the site, but thanks for the heads up! If this is the case, hopefully it helps others. Have you reported the issues to the plugin developer? Hopefully if it is a plugin issue there is an easy fix.
It’s fine if you are on wordpress.org or com/premium. Regular wordpress.com users aren’t allowed to upload plug ins. Too bad.
Hi, I’ve downloaded and installed the plugin. Hide the post from homepage but it’s still there. My site: fpulseaid.com . The article is under health and beauty. How do I remove it from the homepage? Do I need to create a page for the ‘Home’?
Please have a look at the recommended plugins in the article, the first plugin can be used to exclude categories such as health/beauty in your case from the homepage.
I am so happy to have found this post! I have been looking endlessly to accomplish this task. Thank you for the great explanation. This solves a big issues I’ve been having, but I was wondering if it is possible to hide posts from the homepage as well as make that same post “sticky” on the other page it will be seen on?
I was wanting to hide all my link parties each week. I hope this will do it. Thanks so much!
my reason for hiding post is to prevent my blogger friends from copying my latest articles before i share it myself . Thanks a lot
This worked great and really solved a problem I thought was going to be a huge hassle. Thank you so much.
I have to tell you I searched up and down for a way to do this – all I could find were query this and that BS and while I am a complete nerd, querying post from my theme was not an option – 3 hours i WONT get back.
Your solution took me 5 minutes, much appreciated!
If my blog page is not the front page how would i use this code to block certain categories from showing up on the actual blog page?
The code will target whatever page is set to display your recent posts whether it’s the front-page or not. If you check out the code snippet you can see it’s using “is_home” as opposed to “is_front_page”. We actually have an article you can check out regarding the WordPress homepage conditionals.
Hi
have you a solution for the WP Hide Post Plugin who doesn’t works on php7 ?
Many thx
Phil
orrrr you could do this with a little bit of css. here’s what i did
Yes, you could use CSS but if the posts have any images you are loading the images and slowing the site loading time for no reason, hidden content is bad for SEO and in many themes it could break your layout (if it’s a grid style layout).
Hi, thanks for this article. It was really helpful, specially many people just put spam posts.
I’m looking for a way to hide a post from my site and RSS feed, but have Google index it, as well as have it not interfere with my pushing it out to syndication using the SimpleFeed plug-in. Do you know if the plug-in allows me that level of control?
My understanding is that while WP Hide Posts can be used to keep your post from appearing on your homepage or RSS feed, it should not effect Google’s ability to index the page (assuming there is a way for Googlebot to find the page or alternatively you can always request a page to be indexed from your Google Search Console). As for compatibility with SimpleFeed, that is something you will need to ask the plugin deveclopers about, as I don’t personally if or how well they’d work together.
Thanks, Tom Ewer, it works fine.
I love this plug-in and my website design relies on it. However, this week I noticed that the “Hide on” controls have disappeared from the post settings. Is it because the plugin is outdated? (It has been tested up to WP 6.4.4, but the latest version of WP is 6.5.2.) HELP!
Hmmm it should still work with the current version of WordPress. I wonder if you need to make the options visible by checking them within the “Screen Options” at the top of your Posts.