Trying to get property of non-object in ‘…/ultimate-faqs/Main.php’ on line 127
-
With WordPress debugging turned on, when I visit most any admin page, I see the message:
Notice: Trying to get property of non-object in /home/holycowom/public_html/www.VillageHillCommunity.org/wp-content/plugins/ultimate-faqs/Main.php on line 127
This is a problem in the second line of this block of code:
if ($hook == 'edit.php' or $hook == 'post-new.php' or $hook == 'post.php') { if ($post->post_type == 'product') { wp_enqueue_script('ewd-ufaq-wc-admin', plugins_url("js/ewd-ufaq-wc-admin.js", __FILE__, array('jquery'))); } }
I believe you need to protect for a null $post variable with ‘isset($post)’. Here’s my updated code that seems to resolve the problem for me:
if ($hook == 'edit.php' or $hook == 'post-new.php' or $hook == 'post.php') { if (isset($post) && ($post->post_type == 'product')) { wp_enqueue_script('ewd-ufaq-wc-admin', plugins_url("js/ewd-ufaq-wc-admin.js", __FILE__, array('jquery'))); } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Trying to get property of non-object in ‘…/ultimate-faqs/Main.php’ on line 127’ is closed to new replies.