我使用这段代码在woocommerce中隐藏产品类别。
add_filter( 'get_terms', 'filter_get_terms', 10, 3 );
function filter_get_terms( $terms, $taxonomies, $args ) {
$new_terms = [];
// if a product category and on the shop page
if ( ! is_admin() ) {
foreach ( $terms as $term ) {
if ( ! in_array( $term-> slug, [ 'seinakellad', 'nastennye-chasy', 'wall-clock', 'juuksekammid', 'grebni-dlja-volos', 'hair-combs' ] ) ) {
$new_terms[] = $term;
}
}
$terms = $new_terms;
}
return $terms;
}在更新到PHP8.2之后,我得到了以下错误:
**
警告**:尝试在/data01/virt81820/domeenid/www.enjoythewoodestonia.ee/test/wp-content/plugins/code-snippets/php/snippet-ops.php(505):eval()'d代码上在8行中读取int上的属性"slug“
So...whats的问题与“鼻涕虫”和如何解决它?
谢谢!
发布于 2022-11-30 18:47:28
在主题的functions.php文件中使用以下代码。
add_filter( 'woocommerce_product_categories_widget_args',
'woo_hide_car_category_widget' );
function woo_hide_car_category_widget( $list_args ) {
$list_args['exclude'] = array( 'car' );
return $list_args;
}https://stackoverflow.com/questions/74615412
复制相似问题