Title: Warning Error
Last modified: August 22, 2016

---

# Warning Error

 *  Resolved [tncdesigns](https://wordpress.org/support/users/tncdesigns/)
 * (@tncdesigns)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/warning-error-26/)
 * I just want to report a warning error. This is not urgent but much better if 
   fixed.
 * **Notice: Undefined** index: post in /home/abc/public_html/subabc/wp-content/
   plugins/ns-seo-custom-fields/ns-seo-custom-fields.php on line 234
 * **Warning: Invalid argument supplied for foreach() **in /home/abc/public_html/
   subabc/wp-content/plugins/ns-seo-custom-fields/ns-seo-custom-fields.php on line
   235
 * [https://wordpress.org/plugins/ns-seo-custom-fields/](https://wordpress.org/plugins/ns-seo-custom-fields/)

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

 *  Plugin Author [Never Settle](https://wordpress.org/support/users/neversettle/)
 * (@neversettle)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/warning-error-26/#post-5527736)
 * Thank you very much for reporting this, and we will take a look. Can you please
   provide any other info that might help us identify the cause: do you know what
   type of field it is checking and what the value in that field is?
 * Regards!
 *  Thread Starter [tncdesigns](https://wordpress.org/support/users/tncdesigns/)
 * (@tncdesigns)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/warning-error-26/#post-5527772)
 * line 234 = $post_id = $_GET[‘post’];
 * Fixed:
    global $post; $post_id = isset($_GET[‘post’])?$_GET[‘post’]:$post->ID;——————
   line 235 = foreach(get_option(‘ns_seo_custom_fieldname’) as $fieldname){} I think
   this is the cause get_option(‘ns_seo_custom_fieldname’) it is not set or empty.
 *  Plugin Author [Never Settle](https://wordpress.org/support/users/neversettle/)
 * (@neversettle)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/warning-error-26/#post-5527897)
 * Thank you very much for the suggestion. Is that change working for you?
 * I don’t understand why that fixes it though. Every time you are on a post edit
   page where both SEO for WordPress and NS Custom Fields are processing post metadata
   the url always looks like this:
 * /wp-admin/post.php?post=1&action=edit
 * And therefore the $_GET[‘post’] will always be valid, right? Or maybe I am missing
   something. What is an example admin URL you are on where it is not working for
   you with the old code?
 * Or… I just thought of something – were you maybe having that issue because you
   were on the Add New post edit page before an ID is assigned? A quick work-around
   would be to save the new post draft to get an ID in the URL and then it will 
   work normally.
 * But if you have any other thoughts / feedback that would be great, and we’ll 
   try to make this update as soon as possible.
 * Thanks!
 *  Plugin Author [Never Settle](https://wordpress.org/support/users/neversettle/)
 * (@neversettle)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/warning-error-26/#post-5527899)
 * Actually, I get it now… that is probably exactly what is going on. Bug was affecting
   Add New posts only. Fixed per your suggestion and provided credit to you in the
   code comments and readme.txt. Thank you for the catch and fix!
 *  Thread Starter [tncdesigns](https://wordpress.org/support/users/tncdesigns/)
 * (@tncdesigns)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/warning-error-26/#post-5527914)
 * welcome and thanks for this very useful plugin.
 *  Thread Starter [tncdesigns](https://wordpress.org/support/users/tncdesigns/)
 * (@tncdesigns)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/warning-error-26/#post-5527915)
 * Hi Author,
 * Here’s also I found out that if you enable the wp debug the plugin throws a warning
   in the frontend.
 * **Warning: Invalid argument supplied for foreach() in /home/abc/public_html/sub
   abc/wp-content/plugins/ns-seo-custom-fields/ns-seo-custom-fields.php on line 
   237**
 * What I did to fixed the warning, I did just put a checking of value before passing
   it to foreach.
 * if(get_option(‘ns_seo_custom_fieldname’)){
    foreach(){ …. } }
 * Thanks
 *  Plugin Author [Never Settle](https://wordpress.org/support/users/neversettle/)
 * (@neversettle)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/warning-error-26/#post-5527967)
 * Thanks again for the additional find. We’ll get it incorporated soon!

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

The topic ‘Warning Error’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/ns-seo-custom-fields_5d4634.svg)
 * [NS Custom Fields for WordPress SEO](https://wordpress.org/plugins/ns-seo-custom-fields/)
 * [Support Threads](https://wordpress.org/support/plugin/ns-seo-custom-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/ns-seo-custom-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ns-seo-custom-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ns-seo-custom-fields/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Never Settle](https://wordpress.org/support/users/neversettle/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/warning-error-26/#post-5527967)
 * Status: resolved