Ecommerce Shopify WordPress Discussion

Hide WooCommerce products with a Pending status from homepage

I have a WooCommerce website and I use WCFM multivendor plugin. When any vendor submits a product, it goes in Pending Review status, but the product is showing in the home page and when clicked on the product it shows 404 as the product status is pending and users have no permission to do this. I have tried a lot of different things, but I can't find the solution. I have tried: function exclude_pending_products($query) { // Check if it's the main query and if it's on the front-end if (is_admin() || !$query->is_main_query()) { return; } //Check if it's a product query if ($query->is_post_type_archive('product') || $query->is_tax('product_cat') || $query->is_tax('product_tag')) { //Exclude pending products $query->set('post_status', array('publish')); } } add_action('pre_get_posts', 'exclude_pending_products'); I tried many more things, but none worked.
Maybe your theme homepage is using [products] shortcode to display products, like for example in WooCommerce StoreFront theme… In this case you should try the following: // For products shortcode (Home page?) add_filter( 'woocommerce_shortcode_products_query', 'shortcode_product_query_excl_pending_status', 50, 3 ); function shortcode_product_query_excl_pending_status( $query_args, $atts, $loop_name ){ $query_args['post_status'] = 'publish'; return $query_args; } // For WooCommerce Archive pages add_action( 'woocommerce_product_query', 'product_query_excl_pending_status', 50, 2 ); function product_query_excl_pending_status( $q, $query ) { if ( ! is_admin() && $q->is_main_query() && $q->is_archive() ) { $q->set('post_status', 'publish'); } } Code goes in functions.php file of your child theme (or in a plugin). It could work. Related: Hide on sale products from a shortcode on homepage in Woocommerce

December 29, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.