I've been working on modifying the Thesography plugin to include the Google Maps API. So far I've had success doing so.

I'm looking to take this one step further and have 1 large Google Map that would display all of my images on 1 map. Then when you hover over a marker, an image thumbnail comes up with the post title. I know the requirements for the Google Maps API to make this possible, but am struggling with trying to get the data out of MySQL.

I'm looking for some coding help that'll help me extract the following information from a post, IF it has "latlng_readable" in the post_metadata. For the Google Map, I'd like to be able to grab the post title, the post image URL and the "latlng_readable" meta coordinates for the marker pin.

This way I can put this into the Google Maps API so that in the popup box for my marker is a little thumbnail of the image, as well as the title of that image.

1 Answer 1


Trying using WP_Query() using the meta_query arguments.

Something like this:

$geotag_post_query_args = array(
    'meta_key' => 'latlng_readable'

$geotagged_posts = new WP_Query( $geotag_post_query_args );

Now, $geotagged_posts is a query object, that should include all Posts that have the latlng_readable meta field. You can extract the $post data from this object the same as any other query object.

  • I integrated this into the geotagging plugin I've been modifying, and used print_r to see what the array was holding. It didn't look like anything useful. At the beginning was "WP_Query Object ( [query_vars] => Array ( [meta_key] => latlng_readable [error]" < snip>. Not sure where to go from here.
    – Pat
    Commented Feb 8, 2012 at 21:55
  • What array are you using print_r() on, the arguments array? The data returned by WP_Query() is an object, not an array. Commented Feb 8, 2012 at 22:25
  • That output was from print_r($geotagged_posts);, however when I changed it to print_r($geotag_post_query_args);, I got: NotAvailableArray ( [meta_key] => latlng_readable ).
    – Pat
    Commented Feb 8, 2012 at 22:53
  • Try var_dump( '$geotagged_posts );. Commented Feb 8, 2012 at 23:18
  • My newbieness is showing through I guess. That returned this: array(1) { ["meta_key"]=> string(15) "latlng_readable" }
    – Pat
    Commented Feb 9, 2012 at 2:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.