Skip Navigation

[Resolved] Notice: Trying to get property 'query_type' of non-object

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 15 replies, has 4 voices.

Last updated by amandaD 4 years, 1 month ago.

Assisted by: Nigel.

Author
Posts
#1823339

I'm having this problem too - sorry to reply to a closed thread.

I had written a custom archive page in PHP and I was using get_posts() with the 'fields' => 'ids' argument (ie, my query result was an array of IDs, and $post was just an ID, not an object.)

I didn't think this would be a problem, because this particular page wasn't using any toolset functions in the loop except for toolset_get_parent_post_by_type( ), and I was passing it the ID. I'm still not sure why I was getting this warning - I was passing the right parameter, but anyhoo the logs were complaining about the `is_wpa_helper()` function in

PHP Notice:  Trying to get property 'post_type' of non-object in \wp-content\plugins\toolset-blocks\application\controllers\compatibility\wpa-block-editor\wpa-block-editor.php on line 214

The function it is referring to is:


	private function is_wpa_helper( $wpa_helper_post = null ) {
		if ( ! $wpa_helper_post ) {
			global $post;
			$wpa_helper_post = $post;
		}

		if ( ! $wpa_helper_post ) {
			return false;
		}

		return self::WPA_HELPER_POST_TYPE === $wpa_helper_post->post_type;
	}

I would think it should be a simple matter of putting in a check there for is_object. I won't be the last person who limits their queries to return IDs instead of objects.