Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5969565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:14:55+00:00 2026-05-22T20:14:55+00:00

There is a wonderful example of using Google maps for a store locator here:

  • 0

There is a wonderful example of using Google maps for a store locator here: http://code.google.com/apis/maps/articles/phpsqlsearch_v3.html

The example uses a simple table with 3 columns- address, latitude, longitude.

I’m trying to integrate this in wordpress using Custom Post type for each new location, and i’ve successfully been able to save the address, latitude, and longitude value as meta data along with each new custom post.

What i’m having a hard time doing is pulling this data/Query to convert to XML the same way that the google example provides.

It would be nice to just keep all the data inside WordPress custom posts without creating an entire seperate table to handle it.

Here is the standard example query:

// Search the rows in the markers table
$query = sprintf("SELECT address, name, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",
  mysql_real_escape_string($center_lat),
  mysql_real_escape_string($center_lng),
  mysql_real_escape_string($center_lat),
  mysql_real_escape_string($radius));
$result = mysql_query($query);

How would you approach mimicking this to work within wordpress CPT meta data?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:14:56+00:00Added an answer on May 22, 2026 at 8:14 pm

    I’ve figured it out- this is the SQL Query:

    SELECT  wp_posts.post_title as name, 
    address.meta_value as address,
     latitude.meta_value as lat,
     longitude.meta_value as lng,
     telephone.meta_value as telephone,
    
       ( 3959 * acos(
        cos( radians( '%s' ) ) *
        cos( radians( CONVERT( latitude.meta_value, DECIMAL( 10, 6 ) ) ) ) *
        cos( radians( CONVERT( longitude.meta_value, DECIMAL( 10, 6 ) ) ) - radians( '%s' ) ) +
        sin( radians( '%s' ) ) * sin( radians( CONVERT( latitude.meta_value, DECIMAL( 10, 6 ) ) ) )
         ) ) AS distance
    
     FROM wp_posts
     LEFT JOIN wp_postmeta AS address ON(
     wp_posts.ID = address.post_id
     AND address.meta_key = '_dealer_address'
     )
     LEFT JOIN wp_postmeta AS latitude ON(
     wp_posts.ID = latitude.post_id
     AND latitude.meta_key = '_dealer_latitude'
     )
     LEFT JOIN wp_postmeta AS longitude ON(
     wp_posts.ID = longitude.post_id
     AND longitude.meta_key = '_dealer_longitude'
     )
     LEFT JOIN wp_postmeta AS telephone ON(
     wp_posts.ID = telephone.post_id
     AND telephone.meta_key = '_dealer_telephone'
     )
     WHERE wp_posts.post_type = 'dealers' HAVING distance < '%s' ORDER BY distance LIMIT 0 ,      20
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi guys I'm using this wonderful class here to do a bit of code
There is previous little on the google on this subject other than people asking
There are numerous libraries providing Linq capabilities to C# code interacting with a MySql
There are tons of great examples of creating work items using the TFS API,
I'm using Damian Conway's inside-out objects as described is his wonderful book Perl Best
Here's a newbie question on the WPF TabControl, TabItem and TabPanel. There is a
There's a lot of threads here about converting br/> or preserving newlines across different
There seems to have a buzz around the Lightswitch application framework. Reading some posts/forums/articles
I'm using the wonderful Taglist plugin with Vim and I would like to know
There is a conversion process that is needed when migrating Visual Studio 2005 web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.