WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
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 Feb 8 '12 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. – Chip Bennett Feb 8 '12 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 Feb 8 '12 at 22:53
Try var_dump( '$geotagged_posts );. – Chip Bennett Feb 8 '12 at 23:18
My newbieness is showing through I guess. That returned this: array(1) { ["meta_key"]=> string(15) "latlng_readable" } – Pat Feb 9 '12 at 2:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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