Title: Invalid Argument messages
Last modified: August 30, 2016

---

# Invalid Argument messages

 *  Resolved [ae1](https://wordpress.org/support/users/ae1/)
 * (@ae1)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/invalid-argument-messages/)
 * Hi
 * I’ve added 30+ stores to our locator, but i’ve now started to get this message
   when saving:
 * Warning: Invalid argument supplied for foreach() in /home/wayne/public_html/wp-
   content/plugins/wp-store-locator/admin/class-geocode.php on line 157
 * Warning: Cannot modify header information – headers already sent by (output started
   at /home/wayne/public_html/wp-content/plugins/wp-store-locator/admin/class-geocode.
   php:157) in /home/wayne/public_html/wp-admin/post.php on line 242
 * Warning: Cannot modify header information – headers already sent by (output started
   at /home/wayne/public_html/wp-content/plugins/wp-store-locator/admin/class-geocode.
   php:157) in /home/wayne/public_html/wp-includes/pluggable.php on line 1207
 * This has only started once i’ve begun to enter our overseas distributors into
   the list, the UK is fine. However, i’m entering all the same info into the correct
   fields. I’ve tried entering other details, but it just refuses to save.
 * Any help appreciated.
 * Thanks
 * [https://wordpress.org/plugins/wp-store-locator/](https://wordpress.org/plugins/wp-store-locator/)

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

 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/invalid-argument-messages/#post-6820412)
 * If you open the /admin/class-geocode.php and search for _function geocode\_location_(
   should be line 59 ).
 * The first line you see in the function should be this.
 *     ```
       $geocode_response = $this->get_latlng( $post_id, $store_data );
       ```
   
 * Add this code just below it, save the file, and try to add another location.
 *     ```
       echo '<pre>';
       print_r( $geocode_response );
       echo '</pre>';
       exit();
       ```
   
 * This should show the returned data from the Geocode API, and any possible errors.
   If it’s not to much text, can you copy / paste it here, or otherwise take a screenshot
   of the returned data?
 *  Thread Starter [ae1](https://wordpress.org/support/users/ae1/)
 * (@ae1)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/invalid-argument-messages/#post-6820443)
 * Thanks for the response, when i enter new data this is the response…
 * Array
    ( [results] => Array ( [0] => Array ( [address_components] => Array ( [
   0] => Array ( [long_name] => Herning [short_name] => Herning [types] => Array([
   0] => locality [1] => political )
 *  )
 *  [1] => Array
    ( [long_name] => Herning Municipality [short_name] => Herning 
   Municipality [types] => Array ( [0] => administrative_area_level_2 [1] => political)
 *  )
 *  [2] => Array
    ( [long_name] => Central Denmark Region [short_name] => Central
   Denmark Region [types] => Array ( [0] => administrative_area_level_1 [1] => political)
 *  )
 *  [3] => Array
    ( [long_name] => Denmark [short_name] => DK [types] => Array ([
   0] => country [1] => political )
 *  )
 *  [4] => Array
    ( [long_name] => 7400 [short_name] => 7400 [types] => Array ( [
   0] => postal_code )
 *  )
 *  )
 *  [formatted_address] => 7400 Herning, Denmark
    [geometry] => Array ( [bounds]
   => Array ( [northeast] => Array ( [lat] => 56.2819932 [lng] => 9.1831637 )
 *  [southwest] => Array
    ( [lat] => 55.9786648 [lng] => 8.760286 )
 *  )
 *  [location] => Array
    ( [lat] => 56.138557 [lng] => 8.967322 )
 *  [location_type] => APPROXIMATE
    [viewport] => Array ( [northeast] => Array ([
   lat] => 56.2819932 [lng] => 9.1831637 )
 *  [southwest] => Array
    ( [lat] => 55.9786648 [lng] => 8.760286 )
 *  )
 *  )
 *  [partial_match] => 1
    [place_id] => ChIJ_SOAS3G8S0YRasgKh297ivI [types] => Array([
   0] => locality [1] => political )
 *  )
 *  [1] => Array
    ( [address_components] => Array ( [0] => Array ( [long_name] =
   > 7400 [short_name] => 7400 [types] => Array ( [0] => postal_code )
 *  )
 *  [1] => Array
    ( [long_name] => Herning [short_name] => Herning [types] => Array([
   0] => locality [1] => political )
 *  )
 *  [2] => Array
    ( [long_name] => Denmark [short_name] => DK [types] => Array ([
   0] => country [1] => political )
 *  )
 *  )
 *  [formatted_address] => 7400 Herning, Denmark
    [geometry] => Array ( [bounds]
   => Array ( [northeast] => Array ( [lat] => 56.2819932 [lng] => 9.1831637 )
 *  [southwest] => Array
    ( [lat] => 55.9786648 [lng] => 8.760286 )
 *  )
 *  [location] => Array
    ( [lat] => 56.1255662 [lng] => 8.9496583 )
 *  [location_type] => APPROXIMATE
    [viewport] => Array ( [northeast] => Array ([
   lat] => 56.2819932 [lng] => 9.1831637 )
 *  [southwest] => Array
    ( [lat] => 55.9786648 [lng] => 8.760286 )
 *  )
 *  )
 *  [partial_match] => 1
    [place_id] => ChIJ7eq43om7S0YR31Pa3rI36Ek [types] => Array([
   0] => postal_code )
 *  )
 *  )
 *  [status] => OK
    )
 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/invalid-argument-messages/#post-6820446)
 * And if you remove the extra code, and try it again for the same address, it still
   comes up with the invalid argument error? Just to be sure, you didn’t click the“
   Preview Location” button in the editor?
 *  Thread Starter [ae1](https://wordpress.org/support/users/ae1/)
 * (@ae1)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/invalid-argument-messages/#post-6820449)
 * After adding that code and adding the new entry above then when i do in a search
   on the website it doesn’t show the result. but at the same time doesn’t show “
   no results found” as i would usually get.
 * So, removing all that code and trying again…
 * It works! No idea what happened there then.
 * Wayne
 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/invalid-argument-messages/#post-6820538)
 * You are not the first one to run into that error, just never really been able
   to figure out how it happens. It almost looks like the Geocode API sometimes 
   returns data without the coordinates, but sets the status field to OK. That really
   shouldn’t happen.
 * At least it works again, I will see if I can code something around it in case
   the coordinate fields are really empty.
 *  Thread Starter [ae1](https://wordpress.org/support/users/ae1/)
 * (@ae1)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/invalid-argument-messages/#post-6820539)
 * Sadly it doesn’t work again! Well, i can input the data, but it’s now not showing
   any results when i look online, doesn’t even give me the “no result found” screen.
 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/invalid-argument-messages/#post-6820540)
 * Did you set a large enough search radius? What’s the url, and where should I 
   search for?
 *  Thread Starter [ae1](https://wordpress.org/support/users/ae1/)
 * (@ae1)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/invalid-argument-messages/#post-6820542)
 * Yes, I set it for 500 miles (is there a way of removing the search size area?)
 * If you look here for “Liverpool” then it should show no results:
 * [http://scarechasers.com/~wayne/where-to-buy/](http://scarechasers.com/~wayne/where-to-buy/)
 * Thanks
 * Wayne
 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/invalid-argument-messages/#post-6820565)
 * > If you look here for “Liverpool” then it should show no results:
 * If I search for Liverpool it does return “Do Good Audio”, why is this wrong? 
   You can disable all the dropdowns on the settings page -> search section.
 * If you search for something again, and it doesn’t return any results, and also
   no “No results found”. Can you [check](https://codex.wordpress.org/Using_Your_Browser_to_Diagnose_JavaScript_Errors#Step_3:_Diagnosis)
   for JS errors. Maybe one of the scripts sometimes triggers an JS error.

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

The topic ‘Invalid Argument messages’ is closed to new replies.

 * ![](https://ps.w.org/wp-store-locator/assets/icon-256x256.jpg?rev=1007784)
 * [WP Store Locator](https://wordpress.org/plugins/wp-store-locator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-store-locator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-store-locator/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-store-locator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-store-locator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-store-locator/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/invalid-argument-messages/#post-6820565)
 * Status: resolved