简体   繁体   中英

Trying to get property 'ID' of non-object in wp-includes/post.php in Wordpress

I am using wordpress version 5.32 and elementor plugin (2.8)

While i am trying to customize and publish it raise an issue like:

<b>Notice</b>
: Trying to get property 'ID' of non-object in 
<b>/wordpress/wp-includes/post.php</b> 
on line <b>6534</b>
<br />

Line 6534:

function update_post_cache( &$posts ) {
    if ( ! $posts ) {
        return;
    }
    foreach ( $posts as $post ) {
        wp_cache_add( $post->ID, $post, 'posts' );
    }
}

and the change not geting updated in the website.

Disabling the elementor plugin will resolve this problem. How can i fix this issue with elementor plugin.

Instead of

$post->ID

you can use:

$post['ID']

Try this

 function update_post_cache( &$posts ) {
    if (!$posts) {
        return;
    }
    foreach ($posts as $post) {
        wp_cache_add( $post['ID'], $post,'posts');
    }
}

Hope this helps : I had a siliar issue, I noticed that in de database, the table wp_posts had entries with the ID that had a value of 0 .

I deleted those entrys and added an AUTO_INCREMENT (that for some reason was not set) to the ID row of that table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM