Skip to main content
deleted 7 characters in body
Source Link
metalzade
  • 117
  • 1
  • 2
  • 5

I'm using get_the_ID() in my wp_enqueue_scripts action due to some needs, But as result I'm getting the following notice (wp-debug is on):

Notice: Trying to get property of non-object in C:\wamp\www\rosita\WordPress\wp\wamp\www\WordPress\wp-includes\post-template.php on line 29

I know why this happens, My question is why should this happen? Isn't WordPress supposed to know that there is no $post assigned to 404 and return an empty result?

Do I have to use:

if( !is_object($post) ) return;

Everywhere I use get_the_ID() in order to get rid of that Notice?

I'm using get_the_ID() in my wp_enqueue_scripts action due to some needs, But as result I'm getting the following notice (wp-debug is on):

Notice: Trying to get property of non-object in C:\wamp\www\rosita\WordPress\wp-includes\post-template.php on line 29

I know why this happens, My question is why should this happen? Isn't WordPress supposed to know that there is no $post assigned to 404 and return an empty result?

Do I have to use:

if( !is_object($post) ) return;

Everywhere I use get_the_ID() in order to get rid of that Notice?

I'm using get_the_ID() in my wp_enqueue_scripts action due to some needs, But as result I'm getting the following notice (wp-debug is on):

Notice: Trying to get property of non-object in C:\wamp\www\WordPress\wp-includes\post-template.php on line 29

I know why this happens, My question is why should this happen? Isn't WordPress supposed to know that there is no $post assigned to 404 and return an empty result?

Do I have to use:

if( !is_object($post) ) return;

Everywhere I use get_the_ID() in order to get rid of that Notice?

Tweeted twitter.com/#!/StackWordPress/status/410945125163229185
Source Link
metalzade
  • 117
  • 1
  • 2
  • 5

get_the_ID() gives notice in 404 page

I'm using get_the_ID() in my wp_enqueue_scripts action due to some needs, But as result I'm getting the following notice (wp-debug is on):

Notice: Trying to get property of non-object in C:\wamp\www\rosita\WordPress\wp-includes\post-template.php on line 29

I know why this happens, My question is why should this happen? Isn't WordPress supposed to know that there is no $post assigned to 404 and return an empty result?

Do I have to use:

if( !is_object($post) ) return;

Everywhere I use get_the_ID() in order to get rid of that Notice?