How7oHow7o
  • Home
  • Tools
    • All Tools
    • Image Tools
    • Text & String Tools
    • Video Tools
    • Developer Tools
    • PDF Tools
    • Calculators & More
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: Hide Out of Stock Products from Homepage in WooCommerce (Keep Them Visible Elsewhere)
Share
Notification Show More
Font ResizerAa
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
    • All Tools
    • Image Tools
    • Text & String Tools
    • Video Tools
    • Developer Tools
    • PDF Tools
    • Calculators & More
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > 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.
[mc4wp_form]
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

You must be logged in to post a comment.

You Might Also Like

Laravel Eloquent records today — Carbon today helper and whereDate illustration
Web Development

How to Get Records Created Today in Laravel

6 Min Read
Load DataTables data via Ajax
Web Development

How to Load Data in DataTables Using Ajax

5 Min Read
Make Select2 work inside a Bootstrap modal
Web Development

How to Use Select2 Inside a Bootstrap Modal

4 Min Read
Nginx 502 with recv() failed 104 connection reset — PHP-FPM timeout and memory tuning
Server Management

Fix Nginx ‘recv() failed (104: Connection reset by peer)’ with FastCGI

9 Min Read
How7oHow7o

Free browser-based tools, prank screens, and step-by-step tech tutorials. No signup, nothing uploaded.

  • Private by design — your files never leave your device
  • Instant — no signup, no install, no waiting
  • Always free — no trials, no watermarks, no paywalls

Tools

  • PDF Editor
  • Image Upscaler
  • JPEG Compressor
  • Password Generator
  • QR Code Generator
  • Video Trimmer
  • See all tools →

Pranks

  • Cracked Screen Prank
  • Fake Blue Screen (BSOD)
  • Fake Disk Format
  • Fake Low Battery
  • Fake Virus Scan
  • Fake Windows 10 Update
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?