How7o
  • Home
  • Marketing
    MarketingShow More
    The Beginner’s Guide about Facebook Advertising
    6 Min Read
    64 Creative Marketing Ideas to Boost Your Business
    6 Min Read
  • OS
    OSShow More
    How to force quit frozen apps in Ubuntu
    Force Close an App in Ubuntu (xkill, System Monitor, kill -9)
    4 Min Read
    5 Effective Ways to Increase Market Share Online
    6 Min Read
    Tips Debugging with CMS code Optimization Quick
    6 Min Read
  • Features
    FeaturesShow More
    Step by Step Guide to a Technical SEO Audit
    6 Min Read
    10+ Free Tools to Make Your Own Animated GIFs
    6 Min Read
  • Guide
    GuideShow More
    The Ultimate Guide, Easily Make Videos Tutorials
    6 Min Read
    Tips to Keep Your Cloud Storage Safe and Secure
    6 Min Read
  • Contact
  • Blog
Reading: Hide Out of Stock Products from Homepage in WooCommerce (Keep Them Visible Elsewhere)
Share
Subscribe Now
How7oHow7o
Font ResizerAa
  • Marketing
  • OS
  • Features
  • Guide
  • Complaint
  • Advertise
Search
  • Categories
    • Marketing
    • OS
    • Features
    • Guide
    • Lifestyle
    • Wellness
    • Healthy
    • Nutrition
  • More Foxiz
    • Blog Index
    • Complaint
    • Sitemap
    • Advertise
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.
How7o > Blog > Web Development > Hide Out of Stock Products from Homepage in WooCommerce (Keep Them Visible Elsewhere)
Web Development

Hide Out of Stock Products from Homepage in WooCommerce (Keep Them Visible Elsewhere)

how7o
By how7o
Last updated: January 13, 2026
5 Min Read
WooCommerce homepage filter to hide out of stock products
SHARE

I noticed something that was quietly killing my store’s first impression: my homepage product sections were full of Out of stock items. It looked messy, and honestly, it felt like I was advertising products people couldn’t buy.

Contents
  • Best solution: hide out-of-stock products only on the homepage (code method)
    • Step 1: Add this code to your site
    • Step 2: Clear cache (if you use caching)
    • Step 3: Test it properly
  • If you’re using WooCommerce Blocks (no code option)
  • Why I didn’t use the global “Hide out of stock items” setting
  • Common issues (quick fixes)
    • It doesn’t work on my homepage
    • Changes don’t show up
  • Final thoughts

I already knew WooCommerce has a setting to hide out-of-stock products globally (WooCommerce → Settings → Products → Inventory). But that wasn’t what I wanted. I still wanted out-of-stock items to remain visible on category pages and search (for SEO, browsing, and “notify me” type shoppers). I only wanted the homepage to stay clean.

Here’s what worked for me: I filtered WooCommerce product queries only on the homepage so anything with _stock_status = outofstock disappears from homepage grids, while everything stays visible everywhere else.

Hide out of stock products on WooCommerce homepage

Best solution: hide out-of-stock products only on the homepage (code method)

This method is perfect if your homepage shows products using WooCommerce blocks, shortcodes, or theme sections that use WooCommerce’s product query system.

Before you edit anything: If you can, use a child theme (or a Code Snippets plugin) so theme updates don’t overwrite your changes.

Step 1: Add this code to your site

Add the following code to functions.php in your child theme, or paste it into a snippets plugin:

add_filter( 'woocommerce_product_query_meta_query', function ( $meta_query ) {

    // Run only on the homepage/front page
    if ( is_front_page() || is_home() ) {

        // Show ONLY in-stock products on homepage
        $meta_query[] = array(
            'key'     => '_stock_status',
            'value'   => 'instock',
            'compare' => '='
        );

        /**
         * OPTIONAL:
         * If you want to show backorders too, replace the block above with:
         *
         * $meta_query[] = array(
         *     'key'     => '_stock_status',
         *     'value'   => array( 'instock', 'onbackorder' ),
         *     'compare' => 'IN'
         * );
         */
    }

    return $meta_query;

}, 20 );

That’s it. This tells WooCommerce: “When we’re on the homepage, only fetch products that are in stock.” On category pages, search results, and product pages, nothing changes.

Step 2: Clear cache (if you use caching)

If your homepage is cached (very common), you won’t see changes immediately. Clear your cache from:

  • Your caching plugin (LiteSpeed Cache / WP Rocket / etc.)
  • Server cache (if your host provides one)
  • CDN cache (Cloudflare, etc.)

Step 3: Test it properly

  • Pick a product that appears on the homepage
  • Mark it Out of stock in WooCommerce
  • Refresh the homepage — it should disappear
  • Open its category page or search — it should still be visible there

If you’re using WooCommerce Blocks (no code option)

If your homepage is built with the WooCommerce “Products” block (or a similar product grid block), some setups let you filter by Stock status directly in the block settings. If you see an option like “Stock status” or “In stock only,” enable it for homepage blocks.

This is the easiest method when available — but not every theme/block combination exposes the setting. If you can’t find it, the code method above is the most reliable.

Why I didn’t use the global “Hide out of stock items” setting

WooCommerce has a built-in setting to hide out-of-stock products from the entire catalog. That’s fine for some stores, but in my case it caused problems:

  • I still wanted out-of-stock items visible in categories (for SEO + browsing)
  • I didn’t want old product links to feel “missing”
  • I wanted customers to see the product page (and maybe join a waitlist)

So filtering only the homepage gave me the best of both worlds: clean storefront + full catalog visibility.

Common issues (quick fixes)

It doesn’t work on my homepage

  • Your homepage may be using a custom query that doesn’t use WooCommerce’s product query system.
  • Try switching the homepage section to a WooCommerce Products block/shortcode, or tell me what theme/page builder you’re using and I’ll tailor the fix.

Changes don’t show up

  • Clear cache (plugin + server + CDN)
  • Try a private/incognito window
  • Temporarily disable homepage cache to confirm the logic works

Final thoughts

Hiding out-of-stock products from the homepage made my store look instantly cleaner. Customers stop seeing “Out of stock” everywhere, and my homepage feels like a curated selection again — while my categories and search still show the full catalog.

TAGGED:functions.phpOut of StockphpStock ManagementStore OptimizationWooCommerceWooCommerce Blockswordpress

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Check if Laravel scheduler is running (cron + php artisan schedule:run) How to Check if Laravel Scheduler Is Running (Cron + Logs)
Next Article Login to Laravel programmatically without a password (Auth::login and loginUsingId) Login to Laravel Programmatically Without a Password (Auth::login & loginUsingId)
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

FacebookLike
XFollow
PinterestPin
InstagramFollow

Subscribe Now

Subscribe to our newsletter to get our newest articles instantly!
Most Popular
How I Fixed Composer Dependency Errors
How I Fixed Composer Dependency Errors Using the –ignore-platform-reqs Flag (Step-by-Step Guide)
January 12, 2026
Transfer Discourse to a new server
How to Transfer Discourse to a New Server on AlmaLinux (Backup + Restore, Step-by-Step)
January 12, 2026
Installed Discourse on AlmaLinux
How I Installed Discourse on AlmaLinux (Docker Method, Step-by-Step)
January 12, 2026
Installing Docker on AlmaLinux guide
Install Docker on AlmaLinux: Step-by-Step (Docker CE + Compose)
January 12, 2026
Change welcome message on Ubuntu VPS server (MOTD + SSH banner)
Change Welcome Message on Ubuntu VPS (MOTD + SSH Banner)
January 12, 2026

You Might Also Like

Check if Laravel scheduler is running (cron + php artisan schedule:run)
Web Development

How to Check if Laravel Scheduler Is Running (Cron + Logs)

6 Min Read
Fix 409 Conflict error in Laravel (cookies, cache, WAF)
Web Development

How I Fixed the 409 Conflict Error in Laravel (Cookie / Browser / WAF Fix)

7 Min Read
Send a simple email in Laravel using Mail::raw and SMTP
Web Development

How to Send a Simple Email in Laravel (Fast SMTP + Mail::raw)

4 Min Read
Debug PHP like console.log using error_log and server logs
Web Development

How to Debug in PHP Like console.log (echo, error_log, WordPress debug.log)

6 Min Read

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Latest News

  • SEO Audit Tool
  • Client ReferralsNew
  • Execution of SEO
  • Reporting Tool

Resouce

  • Google Search Console
  • Google Keyword Planner
  • Google OptimiseHot
  • SEO Spider

Get the Top 10 in Search!

Looking for a trustworthy service to optimize the company website?
Request a Quote
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?