Search by city

Home Forums Calendar Products Events Calendar PRO Search by city

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #11199
    Cary Bergeron
    Participant

    So I have the task of allowing users to search events by a specific city (whether it be drop down or a search box) and display events in that city preferably in the same format as list view. How might I go about doing this?

    #11201
    Rob
    Member

    Hey Cary. That’ll take a bit of custom dev; let me see if Jonah has any suggestions for an easy way to do it since it’s a bit outside my area of expertise.

    #11236
    Jonah
    Participant

    Hi Cary,

    There is no easy way to do this and it would take a good amount of our time to come up with some solution. I think this is important going forward though and will put it on the list of future enhancements and/or tutorials. For now you’ll have to get someone to do the custom dev for you.

    Regards,
    Jonah

    #13026
    Mathieu
    Participant

    Sure there isn’t, but there are alternatives πŸ™‚
    What i have done is first add a custom field to my events, where i duplicate the city event.
    Now you can make a function using this query to get the events by city:
    $querystr = "
    SELECT wposts.*
    FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
    WHERE wposts.ID = wpostmeta.post_id
    AND wpostmeta.meta_key = 'my_custom_field_city'
    AND wposts.post_type = 'tribe_events'
    AND wpostmeta.meta_value = '". $thesearchcity."'
    ORDER BY wpostmeta.meta_value DESC
    ";

    An easy way to do that is the use tribe plugin Advanced Post Manager to add this custom field.
    If you haven’t create any custom field USING THAT PLUGIN, then replace “my_custom_field_city” in the code by “_ecp_custom_1”.

    Hope it helps πŸ™‚

    #13071
    Rob
    Member

    This is awesome, Matthieu! Thanks for sharing πŸ™‚

    #13111
    Mathieu
    Participant

    Thanks, but last one problem is that we have to use WP_query and we can’t use tribe_get_events (which was pretty useful because of the link it made with venues and organizer)… So if someone has an idea to use both πŸ™‚

    #13112
    Mathieu
    Participant

    Thanks, but last one problem is that we have to use WP_query and we can’t use tribe_get_events (which was pretty useful because of the link it made with venues and organizer)… So if someone has an idea to use both πŸ™‚

    #13120
    Jonah
    Participant

    Hi Mathieu,

    You can totally use WP_query. All you need to do is pass in the ‘post_type=tribe_events’ argument and it will only query for your events.

    I hope that helps.

    – Jonah

    #17791
    Paul
    Participant

    Sorry to drag this one up but i have a similar request.
    I need to display a list of events based on the city, is there no way to query based on the existing city field?

    #17801
    Jonah
    Participant

    Hi Paul, sorry no there is no built in facility to search by city but this thread may offer some helpful hints: https://theeventscalendar.com/support/forums/topic/zip-code-radius-search/

    I’m now closing this thread out.

    #976492
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Search by city’ is closed to new replies.