• Resolved jnorell

    (@jnorell)


    We have wpadverts plugin enabled on a site, and are setting up Replyable
    to email notices of new comments – in the middle of a certain Replyable email the php notice is included:

    Notice: Trying to get property 'post_type' of non-object in /path/to/wp-content/plugins/wpadverts/includes/functions.php on line 520

    That’s with WP Adverts Version 1.3.7

    (You probably don’t need to reproduce it (just check that $post is an object and post_type is set), but if so the comment was a reply to a previous comment, and it was when displaying a custom post type, not native ‘post’.)

    Thanks…

    • This topic was modified 5 years ago by jnorell.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jnorell

    (@jnorell)

    FWIW, the line in Replyable that’s causing this looks to be valid use of this function: echo get_the_post_thumbnail( $subscribed_post->id(), 'medium' ); ($subscribed_post is an instance of Prompt_Post class, not WP_Post, and not in the loop).

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    please try opening a file wpadverts/includes/functions.php and on the line 520 replace the

    
    if( 'advert'==$post->post_type && in_the_loop()) {
    

    with

    
    if( is_object( $post ) && 'advert' == $post->post_type && in_the_loop() ) {
    

    and see if it will hide the error?

    Thread Starter jnorell

    (@jnorell)

    Yes, that did hide the error. Also consider:

    
    if( is_object( $post ) && isset( $post->post_type ) && 'advert'==$post->post_type && in_the_loop() ) {
    

    Thanks!

    • This reply was modified 4 years, 12 months ago by jnorell.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trying to get property ‘post_type’ of non-object’ is closed to new replies.