I am getting these PHP8.0 Warnings from my WordPress site. The warnings are pointing to core code, not anything custom. When I turn debugging on there are no error messages on the site. I also checked the menu and all of the links are accurate. Is anyone able to help me figure out this warning?
[09-Jan-2024 19:21:27 UTC] PHP Warning: Attempt to read property "ID" on null in \wp-includes\post-template.php on line 674
[09-Jan-2024 19:21:27 UTC] PHP Warning: Attempt to read property "post_type" on null in \wp-includes\post-template.php on line 675
if ( is_singular() ) {
$post = $wp_query->get_queried_object();
$post_id = $post->ID; // Line 674
$post_type = $post->post_type; // Line 675
$post
variable is missing on a single post template. Does this error appear on particular pages? Are you doing anything unusual in custom code that would affect the$post
variable? Are you creating some kind of custom route/endpoint that doesn't point to a post?