• Hi i use thes 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?

    Please Help…. i m a noob in PHP

Viewing 1 replies (of 1 total)
  • Plugin Author Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    The problem is the code you put into the widget is not valid. It is not the widget itself. The giveaway is the “eval’d code” section. Those indicate that the errors came from your code in the widget.

    Specifically, you did not declare the $post as a global.

Viewing 1 replies (of 1 total)
  • The topic ‘Error PHP 8’ is closed to new replies.