2021年4月29日星期四

Need help resolvling PHP 8.0 Undefined array key

I am gradually implementing PHP on wordpress sites that I manage and it is very common for me to see PHP Warnings such as "PHP Warning: Undefined array key 'SOME-TERM'" tied to specific themes and plugins. Typically I have just reported these to the developers, but in this case I am working with a plugin that is no longer being supported. I am hoping someone can help me with fixing the code on the script.

Here are the lines of code throwing off the error:

if( $class->args[ 'display_category_description' ] ){              $desc = empty( $cat->description ) ? null : $cat->description;                if( !empty( $desc ) ){                  $header .= '<p class="category-description">'                             . $desc .                             '</p>';              }          }  

I am guessing that this error is being thrown because the "category description" field is blank in some of the database entries --- but I'm not sure of the appropriate syntax to fix this.

https://stackoverflow.com/questions/67326925/need-help-resolvling-php-8-0-undefined-array-key April 30, 2021 at 09:05AM

没有评论:

发表评论