• Hi,

    If I have a post type ‘restaurant’, with coordinate ‘address’, ‘city’, ‘zip code’, I can also use your plugin to find restaurants, right?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    You can use it to find whatever you want, as long as the data is entered in the store locator itself. If you want to use a different source ( post type ), then you will have to make some changes in the code for that to work, and ( this is likely the problem ), have the coordinates available as well. Without the coordinates you can’t make a search.

    What happens is that a user on the front-end fills in a location, that location is turned into a set of coordinates, and the DB is search for other coordinates that fall within the set radius. So without the restaurant coordinates, it’s not possible to search for anything.

    I don’t have time to test it out, but I can point you in the right directions. The main thing is the query that searches for nearby locations once a users started a search. The SQL query by default uses the ‘wpsl_stores’ custom post type, instead of ‘restaurant’. This can be changed with the wpsl_sql filter, but you will also have to make sure the correct meta fields are used to get the coordinates for of the restaurants.

    So maybe it’s easier to move the locations details from the restaurants in the WPSL plugin itself, instead of making the code modifications to make it work with another custom post type?

    Thread Starter bruinkid

    (@bruinkid)

    I can see what you are saying. This might work if post type is ‘restaurant’. But this can’t work if our post type is ‘house’ and we have other search criteria filter after this search as first step search in homepage. Basically the SQL query use coordinates like wpsl_zip and wpsl_address . How can we change that to our own coordinate name like house_zip and house_address?

    Plugin Author Tijmen Smit

    (@tijmensmit)

    Basically the SQL query use coordinates like wpsl_zip and wpsl_address . How can we change that to our own coordinate name like house_zip and house_address?

    The fields that are used are wpsl_lat and wpsl_lng, if you rename those fields in the query to the fields you want to use that fold the coordinates, then it should work.

    I never tried it myself, but instead if WHERE posts.post_type = 'wpsl_stores' you should be able to make it go through both the ‘restaurant’ and ‘house’ custom post type, but this will probably turn into a complicated query, since you will also need to make sure it goes through both meta fields holding the coordinates for both post types.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Support for post type’ is closed to new replies.