admin管理员组

文章数量:1122832

Is there a way to query posts for "the loop". But include some filter on the results based on a mySQL Function like St_Distance_Sphere? Or convert a wpdb->query into a form similar to "the loop?"

I have wordpress coordinates stored in the wordpress database. I loop through the Posts throughout my templates and am hoping to use the St_Distance_Sphere function on this query to filter the posts. This example SQL is just something I pulled to demonstrate St_Distance_Sphere.

    select
  address_id
from
  geo_data
where
  (
    ST_Distance_Sphere(
      point(longitude, latitude),      -- Columns on the geo_data table
      point(-97.745363, 30.324014)     -- Fixed reference point
    ) *.000621371192
  ) <= 1;    

I am hoping to somehow add this where clause to my existing post query to include it in a template similar to adding args to a wordpress post query for "the loop".

本文标签: loopWordpress Post Query Using Custom native MySQL like StDistanceSphere