Title: Problem with CSS in PHP 8.2
Last modified: December 13, 2022

---

# Problem with CSS in PHP 8.2

 *  Resolved [mrloco](https://wordpress.org/support/users/mrloco/)
 * (@mrloco)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/problem-with-css-in-php-8-2/)
 * I used this code to hide certain product categories in woocommerce with code 
   snippets.
 *     ```
       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
   8
 * Can help me to fix it?
 * Thanks!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fproblem-with-css-in-php-8-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/problem-with-css-in-php-8-2/#post-16540238)
 * Hi [@mrloco](https://wordpress.org/support/users/mrloco/),
 * It’s worth noting that the array of `$terms` that this filter handles might be
   an array of term IDs instead of term objects, depending on what the `output` 
   attribute is set to.
 * As such, if you want to access properties like the slug then you’ll need to convert
   the term into a proper `WP_Term` object before doing so:
 *     ```wp-block-code
       add_filter( 'get_terms', function ( $terms ) {
       	if ( is_admin() ) {
       		return $terms;
       	}
   
       	$new_terms = [];
       	$invalid_slugs = [ 'seinakellad', 'nastennye-chasy', 'wall-clock', 'juuksekammid', 'grebni-dlja-volos', 'hair-combs' ];
   
       	foreach ( $terms as $term ) {
       		$term_object = get_term( $term );
   
       		if ( $term_object && ! is_wp_error( $term_object ) && ! in_array( $term_object->slug, $invalid_slugs ) ) {
       			$new_terms[] = $term;
       		}
       	}
   
       	return $new_terms;
       } );
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Problem with CSS in PHP 8.2’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/problem-with-css-in-php-8-2/#post-16540238)
 * Status: resolved