Hiding WordPress Posts: When, Why & How

Have you ever needed to temporarily unpublish a post without deleting it? Or create exclusive content for paid members? There are good reasons for hiding WordPress posts, if done properly.

Why Hide Posts in WordPress?

According to W3Techs, WordPress powers over 43% of all websites, with millions more posts and pages added daily. But sometimes, you may want to hide published content from public view or search engines. Common reasons include:

  • Testing content with a limited audience
  • Creating exclusive member content
  • De-emphasizing outdated posts
  • Preparing drafts or unpolished content

Of course, you don‘t want to permanently delete quality content. Hiding it selectively improves flexibility and control without duplicating posts.

By the Numbers: Content Overload

The rise of content marketing also contributes to the need for better content controls like hiding posts. Consider these statistics:

  • 50+ million new WordPress posts and pages per month [source]
  • Avg publication creates 20-35 posts per month; enterprises publish way more [source]
  • But 75% of website content goes unused [source]

With so much content, it‘s not feasible for all pages to appear prominently. Selectively hiding content helps declutter your site while retaining unpublished posts.

Method #1: Hide Posts Plugin (Easiest)

The simplest approach for most users is the Hide Posts WordPress plugin with over 40,000 active installs.

Pros:

  • Hides posts from homepage, search, author archives, etc
  • Also works for pages and custom post types
  • Easy checkboxes directly on the post editor page

Cons:

  • Need coding skills for advanced customization
  • Won‘t hide from cached pages or XML sitemaps

The plugin puts hide/show toggles directly on the post editor screen (checkboxes shown earlier). Just activate, check options for the desired post, and hit Publish/Update. This adds code behind the scenes without needing custom scripts.

It takes 1 minute to hide an existing published post this way!

Method #2: Custom Code Snippets

For complete flexibility over hiding logic, developers can use custom code snippets hooked into WordPress queries. Popular hiding plugins actually use similar internal code.

This method has the advantages of:

  • Hiding posts from absolutely any public page
  • Very customizable display logic
  • Can hide posts from XML sitemaps too

The downsides are:

  • Requires PHP coding skills
  • More complex to set up and manage
  • Risk of site issues if done incorrectly

Let‘s compare the key options for hiding posts programmatically:

FeaturePlugin CodeCustom Code
Hide From Homepage
Works For All Post Types
Also Hide From XML Sitemaps
Easy For Beginners
Risk Of Site IssuesLowHigh

As you can see, custom code is extremely powerful but also complex. I recommend WPCode for easily adding snippets safely.

Here is a sample function to hide posts 234 and 567 from archives, feeds, and search:

function hide_my_posts($query) {
  if (is_archive() || is_feed() || is_search()) {
    $query->set(‘post__not_in‘, [234, 567]);
  } 
}
add_action(‘pre_get_posts‘,‘hide_my_posts‘); 

The possibilities are endless!

In Closing: Who This Helps

Selectively hiding published posts benefits:

✅ Bloggers emphasizing new content
✅ Publishers creating gated member content
✅ Marketers doing staggered content releases
✅ Developers privately testing new features

And the options work for any WordPress site owner.

I hope this guide gave you a comprehensive overview of hiding WordPress posts – the reasons, statistics, major methods, and custom code samples. Let me know if you have any other questions!

Ryan Sutter
WordPress Consultant & Developer

We will be happy to hear your thoughts

      Leave a reply

      TechUseful