Taxonomy Passing Along Additional Data
Author | Posts |
---|---|
May 11, 2013 at 1:05 pm 3504 | |
Tareq Hasan | Hey Guys! I've run into a problem I need a little help The template I am using implements a custom post type as a "directory" In this directory, the taxonomy is related to geographic locations. Atlanta, Georgia - Knoxville, Tennessee - etc. I am looking for a way to pass along additional data (GPS coordinates) related to the locations listed in the taxonomy to populate a (preferably hidden) field. So, as a user selects "Atlanta, Georgia" from the taxonomy drop-down...it in turn would reflect "XXX.XXXX" in a latitude field and "XXX.XXXX" in a longitude field. I know that it's going to take some PHP wizardry in the functions file. The coordinates could even be coded in the file itself- as the locations will not change any time soon. Any pointers? Thanks in advance! |
May 11, 2013 at 3:08 pm 3512 | |
Tareq Hasan | I am not sure how your theme is saving that info for those taxonomy, cause WP doesn’t have any method to save taxonomy meta. Only can be possible with some other plugin, like Taxonomy Metadata. [php] // save latitude and longitude add_action( ‘wpuf_add_post_after_insert’, ‘wpufe_tax_meta’ ); |
May 11, 2013 at 3:54 pm 3515 | |
tripod0502 | Tareq, Thanks for the fast response! I don’t know how you do it…but, you are the man. You may remember dealing with another user in regards to the AIT Directory theme…where you gave us the code below… [php] $def_lat = $def_long = 0; if ( isset( $_POST[‘location’] ) ) { $ait_dir_item = array ( update_post_meta( $post_id, ‘_ait-dir-item’, $ait_dir_item ); add_action( ‘wpuf_add_post_after_insert’, ‘wpufe_ait_integration’ ); [/php] But, instead of geocoding the address given in the form, I’m looking to use the latitude and longitude from the meta of the “location” taxonomy…so that users can only choose specified locations, which will be show themselves on the theme’s integrated Google map. |
May 11, 2013 at 4:12 pm 3516 | |
tripod0502 | I hate to sound ignorant…but, would “Ultimate Taxonomy Manager” (http://taxonomymanager.wordpress.com/) work the same way as Taxonomy Metadata? I’ve used it to create two custom taxonomy fields named “gpslatitude” and “gpslongitude” |
May 11, 2013 at 4:33 pm 3517 | |
Tareq Hasan | I can’t actually say if it will work or not, it should work. Somehow the taxonomy is saving extra data into database right? So you’ve to save it too and I gave you the placeholder area in the code where you need to save that data to the right place 😉 |