Problem with hiding categories with PHP 8.2
-
I used this code to hiding product categories in 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; }After updating to PHP 8.2 I got this error:
**
Warning**: Attempt to read property “slug” on int in /data01/virt81820/domeenid/www.enjoythewoodestonia.ee/test/wp-content/plugins/code-snippets/php/snippet-ops.php(505) : eval()’d code on line 8So…whats the problem with that “slug” and how to fix it?
Thanks!
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Problem with hiding categories with PHP 8.2’ is closed to new replies.