Adding Category Filter to Search

Home Forums Calendar Products Events Calendar PRO Adding Category Filter to Search

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #78737
    cmeigs
    Participant

    I’m attempting to add a category filter to a search and I’m attempting to follow the “How to Add Filters” tutorial here: https://theeventscalendar.com/understanding-the-tribeeventsbar/

    The first part of this tutorial (setup_my_field_in_bar) works great, I’m able to create some HTML that displays a dropdown list of categories. My issue arises when I get to the second part (setup_my_bar_field_in_query) that is supposed to put the new field in the query for events.

    When I view my HTML I can see my drop down contained within a form that looks like this:

    but when I submit I do not see my new field contained within the POST.

    My questions are as follows:

    1) How do I submit my category search HTML and have it show up in the $_REQUEST object of the “tribe_events_pre_get_posts” filter/hook?

    2) Once I can get a handle of the new search criteria, how do I apply it to the events query? Do I add it here: $query->query_vars[‘category_name’]? And if I do will it automatically be filtered by this new field?

    #79125
    Barry
    Member

    Hi cmeigs,

    Unfortunately this forum is not currently a great location in which to share code: please use a service like Pastebin or Gist, otherwise it’s quite likely that your code will be stripped from any posts/replies that you make (we do hope to improve things in the future, though).

    Unfortunately, I’m afraid we can’t offer too much support for customizations like this (beyond offering general pointers, which this overview basically accomplishes). What I would say though is that if I basically set up the first two pieces of code from that tutorial then, assuming I do indeed type something into the new field and submit it, the second callback does run and the relevant field is visible within the $_REQUEST superglobal. I’m not sure why are you are not experiencing the same thing.

    For your second question, you can see in the second snippet that the query variables are being modified accordingly – and that is the basic approach you would need to follow.

    As this is very much a custom development question though I am going to have to leave it to you to dig in and figure out the rest. Do also bear in mind that we are developing a filters plugin that may well include this sort of capability.

    Thanks – and good luck!

    #982688
    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 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Adding Category Filter to Search’ is closed to new replies.