Skip to content

Instantly share code, notes, and snippets.

View namwen's full-sized avatar

Will Newman namwen

View GitHub Profile

Keybase proof

I hereby claim:

  • I am namwen on github.
  • I am willnewman (https://keybase.io/willnewman) on keybase.
  • I have a public key whose fingerprint is F970 41A4 9DF0 ECEF 0E58 AD99 8CD2 482C 0D09 9BE5

To claim this, I am signing this object:

@namwen
namwen / Store Locator Geocode
Created August 18, 2013 21:14
Used this in a store locator implementation. When the custom post type was saved, I grabbed the meta info ( address ) and used it to get the lat & long. through Google's geocode API.
add_action('save_post','my_update_shop');
/* add_action('post_updated','my_update_shop'); */
function my_update_shop($post_id){
// Autosaves call this function but mess up the data saved to the DB, so we ignore them
if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ){
return $post_id;
}
// Only go through if we're using the shop post type
if ( $_POST['post_type'] == 'shop'){
// Set up the data from the meta boxes