Hi i use a widget with php code
on php7.4 everything ok
with php 8 i have an error....
Warning: Undefined variable $post in /xxxxxxx/wp-content/plugins/php-code-widget/execphp.php(27) : eval()'d code on line 2
Warning: Attempt to read property "ID" on null in /xxxxxxx/wp-content/plugins/php-code-widget/execphp.php(27) : eval()'d code on line 2
Warning: Undefined variable $post in /xxxxxxx/wp-content/plugins/php-code-widget/execphp.php(27) : eval()'d code on line 3
Warning: Attempt to read property "ID" on null in /xxxxxxx/wp-content/plugins/php-code-widget/execphp.php(27) : eval()'d code on line 3
My code:
<?php
if (get_the_terms($post->ID, 'ausstattung')) {
$taxonomy_ar = get_the_terms($post->ID, 'ausstattung');
echo "";
$output = '<ul>';
foreach ($taxonomy_ar as $taxonomy_term) {
$output .= '<li>'. $taxonomy_term->name .'</li>';
}
$output .= '</ul>';
echo $output;
}
?>
What is wrong?
global $post;