• Hi there,

    In file appear-in-wp.php method respond_to_shortcode() you try to get a post object from the global $post which is already an object (regarding your own code $post->ID).

    The global $post is not an object in front-page.php. I suggest you this improvement with this method :

    public function respond_to_shortcode() {
    
    	// get post object
    	global $post;
    
    	if ( ! is_object( $post ) ) {
    		return;
    	}
    
    	// check if shortcode is present in post content
    	if ( stripos( $post->post_content, '[appear_in' ) !== FALSE ) {
    
    		// call to enqueue scripts and styles needed for shortcode
    		add_action( 'wp_enqueue_scripts', array( $this, 'add_stylesheets_and_javascript' ) );
    
    	} // end if
    
    } // end respond_to_shortcode

    Tell me what you think about that ??
    Thank you and have a nice day.

    • This topic was modified 7 years, 9 months ago by Jan Dembowski.
    • This topic was modified 7 years, 9 months ago by Geoffrey. Reason: bad formatting
  • The topic ‘Notice: trying to get property of non object’ is closed to new replies.