The Easiest Way to Hide Product Prices from Google Search Results in WooCommerce
WooCommerce is a powerful e-commerce platform for WordPress that comes with built-in SEO features, including schema markup for products. By default that means your products are going to show on Google with title, description, reviews, stock status, and product price.
However, there are situations where you might want to hide product prices from Google search results. Perhaps you’re running a catalog of products that pricing simply needs to be hidden, or offer custom pricing based on volume, or only want prices visible to logged-in users. Whatever your reason, there’s a simple way to accomplish this without diving into WooCommerce’s core code.
The Quick and Easy Solution
While it’s possible to edit WooCommerce’s core code to hide prices, this method can be intimidating for beginners and potentially risky. Instead, we have a much simpler solution that only requires a single line of code:
// Hide Product Pricing from Google
add_filter( 'woocommerce_structured_data_product_offer', '__return_empty_array' );
Simply add this line to your theme’s functions.php
file, and you’re done! This code filters out the product offer data (which includes the price) from the structured data that WooCommerce generates for Google.
What Happens After You Hide the Prices?
Once you’ve implemented this change, there are a few important things to keep in mind:
- Clear Your CDN Cache: If you’re using a Content Delivery Network (CDN), make sure to clear its cache after making this change.
- Update Your Sitemaps: Refresh your XML sitemaps to ensure Google has the most up-to-date information about your site structure.
- Google Needs Time to Update: It will take some time for Google to recrawl your site and update its search results. The product prices won’t disappear from search results immediately.
- Request a Recrawl: To speed up the process, you can ask Google to recrawl your site. Google provides instructions on how to do this in their developer documentation.
Potential SEO Impact
It’s important to note that hiding product prices may have some impact on your SEO:
- Product price is a key component that Google likes to display in search results.
- By removing this information, you’re potentially hiding data that Google considers valuable.
- While we haven’t observed significant negative impacts on SEO rankings with this method, it’s possible that future Google algorithm updates could change this.
Hiding product prices from Google search results in WooCommerce doesn’t have to be complicated. With a single line of code, you can achieve this without touching WooCommerce’s core files. Just remember to be patient as Google updates its results, and keep an eye on your SEO performance to ensure this change aligns with your overall marketing strategy.