Title: PHP Notice &#8216;post_type&#8217; of non-object in class-wp-query.php line 4338
Last modified: August 19, 2022

---

# PHP Notice ‘post_type’ of non-object in class-wp-query.php line 4338

 *  Resolved [arianfar](https://wordpress.org/support/users/arianfar/)
 * (@arianfar)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-notice-post_type-of-non-object-in-class-wp-query-php-line-4338/)
 * Hello to all dear ones
    I have a lot of the following error in the error log 
   file:
 * PHP Notice: Trying to get property ‘post_type’ of non-object in /home/***/public_html/***/
   wp-includes/class-wp-query.php on line 4338
 * I put the part of the class-wp-query.php file that includes line 4338 below.
 *     ```
       public function is_singular( $post_types = '' ) {
       if ( empty( $post_types ) || ! $this->is_singular ) {
       return (bool) $this->is_singular;
       }
       $post_obj = $this->get_queried_object();
       line 4338 ===>	return in_array( $post_obj->post_type, (array) $post_types, true );
       }
       ```
   
 * All my plugins and my template are up-to-date
    If possible, guide me on what 
   to do. Thank you very much
    -  This topic was modified 3 years, 8 months ago by [arianfar](https://wordpress.org/support/users/arianfar/).
      Reason: i have a mistake
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-notice-post_type-of-non-object-in-class-wp-query-php-line-4338%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [arianfar](https://wordpress.org/support/users/arianfar/)
 * (@arianfar)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-notice-post_type-of-non-object-in-class-wp-query-php-line-4338/#post-15933139)
 * Hello
    I have a lot of the following error in the error log file:
 * Error at PHP version: 7.4
    PHP Notice: Trying to get property ‘post_type’ of 
   non-object in ***/wp-includes/class-wp-query.php on line 4338
 * Error at PHP version: 8.0
    PHP Warning: Attempt to read property “post_type” 
   on null in ***/wp-includes/class-wp-query.php on line 4338
 * I put the part of the class-wp-query.php file that includes line 4338 below.
 *  public function is_singular( $post_types = ” ) {
    if ( empty( $post_types ) 
   || ! $this->is_singular ) { return (bool) $this->is_singular; } $post_obj = $
   this->get_queried_object(); line 4338: return in_array( $post_obj->post_type,(
   array) $post_types, true ); }
 * I’m getting similar warnings under PHP 8 and also PHP 7.4, with any urls of my
   website, ending with /feed/;
    (the feed link gets displayed, however the warning
   is at the top of the page – each /feed page) I’ve searched for that warning message
   on Google and I can say came up with almost hundreds of websites indexed with
   that warning message in the results. So, it seems that’s a very common problem.
   The warning appears only in /feed/ pages, the mentioned line in php file contains:
   return in_array( $post_obj->post_type, (array) $post_types, true );
 * Tested at all WordPress version: 5 and up
 * All my WordPress and plugins and my template are up-to-date
    If possible, guide
   me on what to do. Thank you very much
 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-notice-post_type-of-non-object-in-class-wp-query-php-line-4338/#post-15933221)
 * In summary, this warning occurs when a /feed/-URL is called?
 * Could you please verify if you are using PHP 8.0 or 8.1? You only wrote “PHP 
   8”. Both versions are supported by WordPress only as “beta support”: [https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/](https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/)
 * Furthermore you could test if disabling plugins helps to get rid of the message.
   The troubleshoot mode of this plugin can help: [https://wordpress.org/plugins/health-check/](https://wordpress.org/plugins/health-check/)
 *  Thread Starter [arianfar](https://wordpress.org/support/users/arianfar/)
 * (@arianfar)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-notice-post_type-of-non-object-in-class-wp-query-php-line-4338/#post-15933857)
 * thank you very mach for replay
    yes, this warning occurs when a /feed/-URL is
   called.
 * I’m currently using version **PHP 7.4**, but I’ve also tested version 8.0
    i 
   disable plugings but when i visit this url:
 * [https://sonarweb.ir/sonarweb.ir/feed/](https://sonarweb.ir/sonarweb.ir/feed/)
 * error added to error_log file
 * i install health-check plugin and test all plugins
    The errors comes from WooCommerce!
   WooCommerce is up to date
 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-notice-post_type-of-non-object-in-class-wp-query-php-line-4338/#post-15933862)
 * Then I would recommend to ask the WooCommerce-support: [https://wordpress.org/support/plugin/woocommerce/](https://wordpress.org/support/plugin/woocommerce/)
 *  Thread Starter [arianfar](https://wordpress.org/support/users/arianfar/)
 * (@arianfar)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-notice-post_type-of-non-object-in-class-wp-query-php-line-4338/#post-15934012)
 * [@threadi](https://wordpress.org/support/users/threadi/) ok
    thank you again

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘PHP Notice ‘post_type’ of non-object in class-wp-query.php line 4338’
is closed to new replies.

## Tags

 * [PHP Notice](https://wordpress.org/support/topic-tag/php-notice/)
 * [PHP Warning](https://wordpress.org/support/topic-tag/php-warning/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [arianfar](https://wordpress.org/support/users/arianfar/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/php-notice-post_type-of-non-object-in-class-wp-query-php-line-4338/#post-15934012)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
