Title: WordPress Update Widget Instance by Passing through Function
Last modified: August 20, 2016

---

# WordPress Update Widget Instance by Passing through Function

 *  [WordsfromWoo](https://wordpress.org/support/users/wordsfromwoo/)
 * (@wordsfromwoo)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/wordpress-update-widget-instance-by-passing-through-function/)
 * 0 down vote favorite
 * I am redoing a google widget wordpress directions with version 3. But while doing
   it I wanted to not have to have someone enter the latitude and longitude of address
   and just use a geo-code call off of the address. Now I only want to call the 
   geocode when the wordpress widget is updated but am having a hard time finding
   out if I can do it. I figure I could just pass the instance through a function
   before updating like below.
    function update($new_instance, $old_instance) { 
   $coords = gmap_geocode($new_instance[‘address’]); $instance[‘address_longitude’]
   = strip_tags(($coords[‘long’])); return $instance; } With gmap_geocode function
   returning the long and lat in a array and then putting the information into an
   instance saved to display on the widgets front end. Is this capable or should
   I just run the geocode every time on the front end? I don’t think that would 
   be best.

The topic ‘WordPress Update Widget Instance by Passing through Function’ is closed
to new replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [instance](https://wordpress.org/support/topic-tag/instance/)
 * [widget](https://wordpress.org/support/topic-tag/widget/)

 * 0 replies
 * 1 participant
 * Last reply from: [WordsfromWoo](https://wordpress.org/support/users/wordsfromwoo/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/wordpress-update-widget-instance-by-passing-through-function/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
