Filtering by State via Venue

Home Forums Calendar Products Filter Bar Filtering by State via Venue

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #963622
    mmirus
    Participant

    So I came across this discussion:

    https://theeventscalendar.com/support/forums/topic/how-can-i-change-the-venue-filter-to-show-the-city-or-state-field/

    Which is exactly what I need, but if you could elaborate on the first few steps described by Brook. I know PHP, but actions and filters and hooks get me all confused. Do I create a new file? Or just modify the venue.php?

    #963715
    mmirus
    Participant

    I think this is the right direction:
    https://theeventscalendar.com/knowledgebase/understanding-the-tribe-events-bar/

    I’ve set up a dropdown in the filter bar for all the states, now how do I hook into the query to filter out events/venues not selected in the dropdown? Is it inside this snippet (found in the link above)?:

    function setup_my_bar_field_in_query( $query ){
    if ( !empty( $_REQUEST[‘tribe-bar-my-field’] ) ) {
    $query->query_vars[‘my_var’] = $_REQUEST[‘tribe-bar-my-field’];
    }
    return $query;
    }

    Or do I have to add a hook to pre_get_posts? And if so, can you detail how?

    #963743
    George
    Participant

    Hey Matt,

    There’s unfortunately not much we can elaborate on in addition to what Brook has already shared there – however, to answer your question, hooking into tribe_pre_get_posts_ is required. This is mentioned in that article, which you should refer to, but basically something like this:

    add_filter( 'tribe_events_pre_get_posts', 'setup_my_bar_field_in_query', 10, 1 );

    The filtering from there is itself the tricky / customized / site-specific sort of stuff that we can’t offer much support for. I’m sorry to disappoint!

    Let us know if this helps,
    George

    #963744
    George
    Participant

    Hey Matt,

    There’s unfortunately not much we can elaborate on in addition to what Brook has already shared there – however, to answer your question, hooking into tribe_pre_get_posts_ is required. This is mentioned in that article, which you should refer to, but basically something like this:

    add_filter( 'tribe_events_pre_get_posts', 'setup_my_bar_field_in_query', 10, 1 );

    The filtering from there is itself the tricky / customized / site-specific sort of stuff that we can’t offer much support for. I’m sorry to disappoint!

    Let us know if this helps,
    George

    #963745
    mmirus
    Participant

    I understand. Maybe you can give me a few examples of filtering that might not even be specific to my site? Anything will help. I can stitch just about anything together, I just really don’t understand the syntax involved here. I’m just trying to add a state dropdown filter, it shouldn’t be this hard especially since I own the Pro version. Thanks for your time, either way.

    #963755
    George
    Participant

    Hey Matt,

    I understand your frustration, and we do offer custom code where we can, but the PRO licenses sign you up for updates and support for problems – we can’t include outright customizations under the umbrella of “problems” because there are many complex variables tied to a customization that we can’t cover, and though it might seem convenient at first, would actually likely create more problems for users over time.

    As for your specific customizations, the filtering itself is, like I mentioned, complicated and not in the domain of stuff we can support. But there are indeed some resources you can learn from, and I apologize for not thinking of sharing these originally.

    First and foremost is to simply read through the Filterbar plugin itself – see how other filters that are built into the plugin by default work, and copy and paste as much code as you can from them! 🙂

    For the specifics of sorting things by date, there are two resources that come to mind when I think of this – first is to familiarize yourself withe Meta Data for events and venues in WordPress. We have a whole list of them here → https://theeventscalendar.com/knowledgebase/wordpress-post-meta-data/

    So, for example, if you get the Venue attached to an event, querying for the venue’s _VenueState meta field will give you the Venue’s “State” (if it’s in the US – if not, then use the _VenueProvince instead).

    The other resource is the official WordPress documentation about WP_Meta_Querys themselves – writing a custom WP_Meta_Query may not itself be the best solution for you here, but reading through it will surely at least give you a better understanding of how Meta data works in WordPress and how it related to posts. You can find this documentation here → https://codex.wordpress.org/Class_Reference/WP_Meta_Query

    I hope this information helps – it’s a bit of a complex customization Matt, which is why we can’t offer super-extensive support for it, but if you read through these things, study pre-existing code, have a good backup on your site before you make customizations, and play around with things a while, you should be able to come up with something workable.

    If not, and you want to hire someone to help you, you can email us at [email protected] and ask for a list of freelance developers we often recommend.

    Cheers!
    George

    #963914
    mmirus
    Participant

    Thanks for your help George. I’ll post my solution here when I get it.

    #963960
    George
    Participant

    Cool! I’ll close up this particular ticket for now – if other questions or concerns arise, come on back and open a new thread whenever you’d like 🙂

    Best of luck with your customizations!

    — George

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Filtering by State via Venue’ is closed to new replies.