Support » Fixing WordPress » Incorporating a PHP Function into WP_Query

  • Hi Team,
    I’ll do this in dot points to make life easier on all you helpful people!

    1. I am making a WP Query through a custom post type (“location”).
    2. One of the custom_fields for location is “postcode”.
    3. I need to grab this postcode and run it through a function which works out the distance between that postcode and where the user is; using another SQL database of postcode distances
    4. I then want the result to be the sorting factor of this WP_Query so that I can cycle through all of them in order of distance apart
    5. I also want to limit the results to a particular distance away (e.g. Only show those less than 100km in that PHP function).

    I have the query made and it can go through ALL of the locations perfectly, and the postcode custom_field returns great, but I can’t work out how to use it in the original query!

    Thanks very much for the help!

  • The topic ‘Incorporating a PHP Function into WP_Query’ is closed to new replies.