Skip to content

Fix PHP Notice: Trying to get property 'post_content' of non-object #6

@mabho

Description

@mabho

I think you should add an additional check on line 69 of file class-acf-form-shortcode-public.php.

In some specific cases I was getting this message "PHP Notice: Trying to get property 'post_content' of non-object in /var/www/html/wp-content/plugins/acf-form-shortcode-master/public/class-acf-form-shortcode-public.php on line 69"

I changed line 69 from...
if( has_shortcode( $post->post_content, 'show_acf_form' ) ){

to...
if( isset($post->post_content) && has_shortcode( $post->post_content, 'show_acf_form' ) ){

... and the error message is gone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions