Hook for Search Query?

This topic contains 5 replies, has 3 voices, and was last updated by  Naveen Giri 4 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #529222

    T L
    Expired Member
    Post count: 48

    Hi guys.

    I’m looking for a hook for search so that I can modify the query.

    I have a field that allows the vendor to select one or more values. There is also a value of “ALL”. I’d like to override the search for values to include something like OR field=’ALL’ in the query.

    Is there a hook that I can use to modify the query?

    Thanks all,

    Tom

    #529308

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    GD search doesn’t sear h the contents of custom fields. Instead it searches title category description and tags.

    You are saying you have a custom field you want to search? Have you already used the search filter option?

    Based on the options available for search filters which one is closest to what you are trying to do?

    #529421

    T L
    Expired Member
    Post count: 48

    Thanks Alex. My apology for not being more clear.

    I have a custom field with a list of U.S States (50) and one extra value of “All” (1). 51 values total.

    This field is set as a filter in the CPT search. No problem there. All works fine. However, when someone searches say “TX” for Texas, we need to filter on all records that have the value of “TX” OR “All”.

    I recognize that this is geographic in nature on the surface but there will be other similar dropdowns that are not geographic values where there will be and “All” type value.

    If I was writing my own code, I would just append some like “or area=’All'” to any queries. That’s why I was asking about a hook that I could modify the query logic or similar approach.

    Thanks

    #529425

    Alex Rollin
    Moderator
    Post count: 27815

    Ah, ok. Thank you for the additional details. I will flag your topic for the developers who will share any advice they can.

    #529433

    T L
    Expired Member
    Post count: 48

    Looking through the source, it seems that the “geodir_posts_where” hook is what I’m looking for unless the Dev’s have a cleaner place to hook into this. Thanks!

    #530130

    Naveen Giri
    Moderator
    Post count: 1559

    Hi, geodir_posts_where will work as per what i understood.

    if that doesnt work. let me know the site url and details. I will check thee data field and revert back.

    Thanks

Viewing 6 posts - 1 through 6 (of 6 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket