• This may not be a very practical example, but when previewing a post with no content in the post edit screen, the following error is logged on the server, even if no shortcodes are set:

    PHP Warning: Attempt to read property “post_content” on null in /home/production/www/mydomain.com/wp-content/plugins/table-of-contents-plus/includes/class-toc-plus.php on line 1533

    The relevant part seems to be the following:

    $custom_toc_position = has_shortcode( $post->post_content, 'toc' );

    Another cause seems to be that “Attempt to read property ‘—-‘ on null” has become a warning in PHP 8.0.

    Personally, I believe the error will not be logged if the following code is added before the above line:

    if ( !isset( $post->post_content ) ) {
    return false;
    }

    Thank you in advance for your assistance.

Viewing 1 replies (of 1 total)
  • George

    (@giorgos93)

    I have the exact same error. It also appears on some other plugins on my website. One developer has already fixed it.

    Please, fix it too.

Viewing 1 replies (of 1 total)
  • The topic ‘PHP Warning: Attempt to read property “post_content”’ is closed to new replies.