Uncaught TypeError: Cannot use ‘in’ operator to search for ‘length’ in
I had this error on a WordPress website for a customer.
Uncaught TypeError: Cannot use 'in' operator to search for 'length' in
The error was related to the plugin WP Store Locator. The Store Locator wouldn’t load the locations and would only show one Google Maps marker. The code inspector pointed me to the admin-ajax.php file which was involved.
The strange thing was that it does show the Store Locations to logged in users but would not show them to not logged in users!
- I tested deactivating the cache plugin (WP Rocket) with no result.
- I tested the website with a clean TwentyTwenty theme and the error was gone.
- I turned off the added functions in the functions.php of my (child) theme and the error was gone.
After digging through the functions.php of my (child) theme I found the function and action which caused the error.
I hope this helps others!