How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: Hide Out of Stock Products from Homepage in WooCommerce (Keep Them Visible Elsewhere)
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • 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.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Bun runtime — faster JS toolkit replacing npm in Laravel projects
How to Install Bun Runtime on Ubuntu (And Use It in a Laravel Project)
May 24, 2026
Tailscale mesh — peer-to-peer connections between devices, coordination server
How to Install Tailscale on Ubuntu (Zero-Config Mesh VPN for Self-Hosters)
May 24, 2026
Caddy server — automatic HTTPS, 3-line Caddyfile vs 25-line nginx config
How to Install Caddy Server on Ubuntu (Automatic HTTPS, Drop-in nginx Alternative)
May 24, 2026
Cloudflare Tunnel — outbound-only connection from server, no inbound port forward
How to Install Cloudflare Tunnel on Ubuntu (Expose Local Services, No Port Forwarding)
May 24, 2026
WireGuard encrypted tunnel between server and clients with lock icons
How to Set Up WireGuard VPN on Ubuntu (Server, Linux Client, and iOS)
May 24, 2026

You Might Also Like

Duplicate a div into another div with jQuery clone
Web Development

How to Duplicate a DIV into Another DIV with jQuery

4 Min Read
Format a PHP number with leading zeros — sprintf and str_pad
Web Development

How to Format a Number with Leading Zeros in PHP

4 Min Read
WooCommerce add custom fee — woocommerce_cart_calculate_fees + WC()->cart->add_fee
Web Development

How to Add a Custom Fee (or Transaction Fee) in WooCommerce

8 Min Read
Laravel updateOrCreate method shown in an Eloquent code snippet with insert and update branches
Web Development

Laravel updateOrCreate: Insert or Update Records in Eloquent

8 Min Read
How7o

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

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • 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?