Title: Fatal error: Uncaught TypeError: count(): Argument #1
Last modified: December 19, 2022

---

# Fatal error: Uncaught TypeError: count(): Argument #1

 *  [ata380](https://wordpress.org/support/users/ata380/)
 * (@ata380)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/php-warning-undefined-array-key-action/)
 * Hello,
 * I am continually getting a server error with the plugin (i’ve used the plugin
   before to great success on other sites we’ve built). Here’s the page where we
   have WP Locator working (or not working, as it were): [https://www.beckettcorp.com/find-a-beckett-distributor/](https://www.beckettcorp.com/find-a-beckett-distributor/)
 * We’ve turned off all other plugins and even switched the theme (it’s using the
   DIVI theme) to see if we could get it to work and nothing worked. The only think
   that seemed to get it to work was to completely delete it from the site and re-
   install… which was problematic because we had to then re-import all 3,200 locations
   as well. And even after doing all that, it seemed to work for a couple of days
   and now i’m getting the same error. The console says the error is:
 * **_Failed to load resource: the server responded with a status of 500 () [https://www.beckettcorp.com/wp-admin/admin-ajax.php?action=store\_search&lat=41.38949&lng=-82.01903&max\_results=25&search\_radius=50&autoload=1](https://www.beckettcorp.com/wp-admin/admin-ajax.php?action=store_search&lat=41.38949&lng=-82.01903&max_results=25&search_radius=50&autoload=1)_**
 * I spoke to WP Engine (hosting the site) about the potential issue with the access
   to admin-ajax.php being blocked as noted in your documentation: [https://wpstorelocator.co/document/map-does-not-load-no-results/#admin-ajax-blocked](https://wpstorelocator.co/document/map-does-not-load-no-results/#admin-ajax-blocked)
 * They told me that the admin-ajax.php being blocked is not, indeed, the issue 
   in this case — rather, they are pointing to a PHP Fatal error which they mentioned
   i needed to send your way:
 * **_68 PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must
   be of type Countable|array, null given in /nas/content/live/beckettcorp/wp-content/
   plugins/wp-store-locator/frontend/class-frontend.php:560_**
 * Please let me know what i need to do to get this fixed on the site when you get
   a sec.
 * Thank you.
 * Daniel
    -  This topic was modified 3 years, 5 months ago by [ata380](https://wordpress.org/support/users/ata380/).
    -  This topic was modified 3 years, 5 months ago by [ata380](https://wordpress.org/support/users/ata380/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-warning-undefined-array-key-action%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [farroyo](https://wordpress.org/support/users/farroyob/)
 * (@farroyob)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/php-warning-undefined-array-key-action/#post-16307089)
 * Hi there!
 * We are aware of this issue happening to some users in some occasions. Long story
   short, in some edge cases, something that should be an array turns out to be 
   a <null> value.
 * Please do this change in the contents of line 560 in the frontend/class-frontend.
   php file from:
 *     ```wp-block-code
       $hour_count = count( $hours[$index] );
       ```
   
 * to
 *     ```wp-block-code
       $hour_count = ( is_array( $hours ) && array_key_exists( $index, $hours ) ) ? count( $hours[$index] ) : 0;
       ```
   
 * This is actually a small but annoying bug, and it will be fixed in the upcoming
   v3.0 of wp store locator, which will be released soon. I will remind the dev 
   team, though, in case they consider releasing a hotfix for this in the current
   version.
 * Let me know if you need help implementing the mentioned change.
 * Apologies!
 *  Thread Starter [ata380](https://wordpress.org/support/users/ata380/)
 * (@ata380)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/php-warning-undefined-array-key-action/#post-16307264)
 * Thank you so much for your help… that seemed to do the trick!

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

The topic ‘Fatal error: Uncaught TypeError: count(): Argument #1’ 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/)

## Tags

 * [admin-ajax.php](https://wordpress.org/support/topic-tag/admin-ajax-php/)

 * 2 replies
 * 2 participants
 * Last reply from: [ata380](https://wordpress.org/support/users/ata380/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/php-warning-undefined-array-key-action/#post-16307264)
 * Status: not resolved