Question

I have a post_type named properties, with the fields prop_address, prop_lat, prop_lng (for google map) and a function in php for computing those last values from the address one. Now: I have imported a massive amount of property posts, now I have them all, with the address set, but lat,long not. In the add - property admin page (in dashboard) there is a button "Place pin from address" thats triggers that function, and filling the lat, long fields.

How can I generate a click event for all posts / call that function easily?

Was it helpful?

Solution

Trigger "Place pin from address" (I'm assuming this uses PHP and not JS) on the save_post hook. Then do a loop of all property posts and run wp_update_post on each (which will fire the save_post hook).

If the place pin from address is using JS then you'll need to replicate that functionality in PHP to use the above method. There's a class that will help you do just that.

Useful links:

https://github.com/jstayton/GoogleMapsGeocoder http://codex.wordpress.org/Plugin_API/Action_Reference/save_post http://codex.wordpress.org/Function_Reference/wp_update_post http://codex.wordpress.org/Template_Tags/get_posts

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top