【发布时间】:2018-03-13 09:00:48
【问题描述】:
我们使用以下代码隐藏具有“未分类”类别的产品:
add_action('pre_get_posts', 'custom_pre_get_posts_query');
function custom_pre_get_posts_query( $q ) {
if (!$q->is_main_query()) return;
if (!$q->is_post_type_archive()) return;
$q->set('tax_query', array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => 'ukategorisert',
'operator' => 'NOT IN',
)
));
remove_action('pre_get_posts', 'custom_pre_get_posts_query');
}
但由于某种原因,存档最终会在每个页面上显示不同数量的产品。好像产品被隐藏了,但在分页中仍然算作产品?
我们找不到此问题的原因或解决方案。请帮忙。
【问题讨论】:
标签: php wordpress woocommerce product custom-taxonomy