我有一个WooCommerce website和我使用WCFM多供应商插件.当任何供应商提交一个产品,它会在等待审查的状态,但该产品显示在主页上,当点击该产品时,它显示404作为产品状态待定,用户没有权限这样做.我已经尝试了很多不同的事情,但我找不到解决方案.
我试过:
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');
字符串
我尝试了很多方法,但没有一种有效。
1条答案
按热度按时间siotufzp1#
也许你的主题主页使用
[products]
简码来显示产品,例如在WooCommerce StoreFront主题中.在这种情况下,你应该尝试以下操作:字符串
代码放在你的子主题的functions.php文件中(或者插件中)。它可以工作。
相关:隐藏在Woocommerce主页上的短代码的销售产品