How to Hide a Post From Homepage in WordPress in 2021

This post was last updated on October 18th, 2021 at 03:27 pm

You may possibly have desired to cover up a website post out of the WordPress homepage or blog archive page.

Even though it’s possible to create a WordPress post password protected or private, in a few instances, you will only need to hide the post from your homepage while allowing the others to visualize it if they have got the link.

Inside the following article, we’ll explain how to hide a post from selected pages chosen from WordPress, such as home page, search results and category archives, and much more.

Must Read: Read our detailed guide on Hostinger hostings.

Procedure 1 # Hide a Post from Homepage With a Plugin

This system is more straightforward, and it’s advised for beginners. The very first thing that you need to do is set up subsequently activate the WordPress Hide Posts Plugin.

WordPress Hide post plugin

When the plugin is activated, proceed up and edit the post that you wish to hide. You will observe a brand new hide post section in the most right column of the editors.

hidepost setting

Clicking on the plugin is going to show plugin choices. It’s possible to hide the post from the front web page and site page, type or label web pages, writers page, page, and blog search success.

Just choose the choices you prefer and save your article. Determined by the selections that you picked, it’s possible to now stop by the pages, and then this specific article isn’t going to be listed.

All users using the straight post URL can currently notice by entering into the URL.

Though this way is the most straightforward, it lacks a few successful choices.

For instance, you cannot hide a page or custom-made post similar to a Woo Commerce product. In addition, it has not the possibility to hide articles from the WordPress RSS feed.

Must Read: Read our detailed guide on GeneratePress Theme. 

Producer 2 # Easily Hide WordPress Posts and Pages

This system takes you to add code to your WordPress website. WordPress employs a database question to both bring and display articles depending on the webpage a user is watching. Additionally, it offers built-in hooks to alter the issue before running it.

We’ll utilize those hooks to alter the WordPress query and then hide the WordPress post, pages, and custom post type in distinct segments.

You may bring custom code working with the code snippets plugin that will be more powerful and can not violate your internet site.

Instead, you may include the custom code into your theme’s functions.php document or some site-specific plugin.

You may even want the IDs of these pages or post you would like to hide. We’ve got a fast tutorial about finding a post Id in WordPress, which shows how to find this information.

Fundamentally, it’s possible to merely edit a page or post to look at its ID on your browser address bar.

wordpressidinaddressbar

That said let us  we dip into the code portion.

Hide Posts or Web pages from Homepage in WordPress

The following code utilizes the is_home() conditional tag to determine whether the user sees this homepage.If they are, subsequently it excludes the article IDs from this query:

function wpb_exclude_from_home($query)

{
if ($query->is_home() )

{
$query->set(‘post__not_in’, array(1737, 1718));
}
}
add_action(‘pre_get_posts’, ‘wpb_exclude_from_home’);

Do not neglect to displace the IDs in the range with the actual IDs of post or web pages which you wish to exclude.

Hide Posts or Web pages from RSS-feed in WordPress

If you’d like to hide a WordPress article from the homepage in addition to the RSS feed, and then you definitely can easily make use of the is_feed conditional tag in the code:

function wpb_exclude_from_feed($query)

{
if ($query->is_feed() ) {
$query->set(‘post__not_in’, array(1737, 1718));
}
}
add_action(‘pre_get_posts’, ‘wpb_exclude_from_feed’);

Now if you’re logged in as an administrator and strove to go to your WordPress RSS feed, you will still find that the articles listed out there. Other users will be unable to observe the excluded post whenever they watch your RSS feed.

Hide Post or Page from Site Search in WordPress

But suppose that you wished to hide specific articles from the WordPress site search. To do so, you may basically ought to bring the is_search conditional tag into the code:

function wpb_exclude_from_search($query)

{
if ( $query->is_search() ) {
$query->set(‘post__not_in’, array(1737, 1718));
}
}
add_action(‘pre_get_posts’, ‘wpb_exclude_from_search’);

Now you can go to your site and look for those posts you wished to hide. While these articles are in the public domain, they won’t be found in search results.

Conceal Post or Page Archives

Believe of concealing special WordPress post or web pages from  record pages including as category , tag , and date archive?  To achieve this, we’ll make use of the is_archive() conditional tag:

function wpb_exclude_from_archives($query)

{
if ( $query->is_archive() ) {
$query->set(‘post__not_in’, array(1737, 1718));
}
}
add_action(‘pre_get_posts’, ‘wpb_exclude_from_archives’);

Hiding Post or Pages from Everywhere

Therefore far, we’ve learned just how to hide WordPress pages or posts from unique locations. But think about entirely hiding a WordPress article from these areas at the same time?

To do so, you’re able to unite all of the conditional tags we utilized early in the day to a code snippet:

function wpb_exclude_from_everywhere($query)

{
if ( $query->is_home() || $query->is_feed() || $query->is_search() || $query->is_archive() ) {
$query->set(‘post__not_in’, array(1737, 1718));
}
}
add_action(‘pre_get_posts’, ‘wpb_exclude_from_everywhere’)

The above Mentioned code may conceal the supplied article from the RSS feed, homepage, archive pages and research results.

Must Read: Read our detailed guide on SEMrush SEO Tools. 

Organizing Content Presence in WordPress

It’s possible to hide WordPress posts or pages utilizing both techniques we clarified previously. Let us answer some of their most often asked queries regarding content visibility control selections in WordPress.

Can all these processes hide articles?

They usually don’t.

As an instance, search engines may have crawled and indexed the post until you may hide it.

And also, this won’t work if your WordPress plugin employs a customized query that skips your check and shows precisely the content you’re working to hide.

An improved way is to password protect a place therefore that users with the password may visualize.

You might also make a private post that’s merely observable to both administrators, editors, and authors on your website.

Could I utilize the following solutions to make articles for specific consumers?

No, These processes usually do not allow you to share quite happy using users that are specific effectively. An excellent way is to make use of a WordPress Membership plugin .

Membership plugins such as MemberPress allow you to make and publish content that is restricted. You may also sell subscription ideas to obtain premium content material.

We expect This informative article assisted you learn to hide WordPress pages or post from of the homepage  and distinct place of your website

Leave a comment