Please help!
I updated my php to 8.0 and my WordPress install to the current version (6.7.1), and now get the following warning messages on my site:
Warning: Undefined variable $post in /home/thespace/public_html/wp-content/themes/mon-cahier/functions.php on line 170
Warning: Attempt to read property "ID" on null in /home/thespace/public_html/wp-content/themes/mon-cahier/functions.php on line 170
Here is the PHP for line 170:
if ( is_singular() && wp_attachment_is_image ( $post->ID ) )
global $post;
{
wp_enqueue_script( 'keyboard-image-navigation', get_stylesheet_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
}
}
add_action( 'wp_enqueue_scripts', 'mon_cahier_scripts' );
How can I fix this and get rid of these warnings on my site?