Home › Forums › Calendar Products › Events Calendar PRO › Search by city
- This topic has 10 replies, 6 voices, and was last updated 8 years, 10 months ago by Support Droid.
-
AuthorPosts
-
November 16, 2011 at 3:50 pm #11199Cary BergeronParticipant
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?
November 16, 2011 at 4:59 pm #11201RobMemberHey 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.
November 17, 2011 at 12:59 pm #11236JonahParticipantHi 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,
JonahJanuary 9, 2012 at 8:35 am #13026MathieuParticipantSure 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 π
January 9, 2012 at 4:55 pm #13071RobMemberThis is awesome, Matthieu! Thanks for sharing π
January 10, 2012 at 2:22 am #13111MathieuParticipantThanks, 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 π
January 10, 2012 at 2:22 am #13112MathieuParticipantThanks, 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 π
January 10, 2012 at 9:19 am #13120JonahParticipantHi 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
April 10, 2012 at 1:26 pm #17791PaulParticipantSorry 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?April 10, 2012 at 8:47 pm #17801JonahParticipantHi 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.
July 6, 2015 at 5:00 pm #976492Support DroidKeymasterThis 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. -
AuthorPosts
- The topic ‘Search by city’ is closed to new replies.