Pre-populated table results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Pre-populated table results

This topic contains 4 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 6 years, 5 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #15378
    nloggans
    nloggans
    Participant

    Hello,

    I’m utilizing your “Staff search and filter” search on the following page:

    http://54.224.95.39/available-courses/

    For this search, I’m wondering if we can pre-populate the table based on a specific category or tag group. I understand there are options based on the type of content (pages, posts, etc.), but I’m wondering if it’s possible to take it to the next level. Such that, it would pre-populate the grid with only blog posts that have the tag “Blue” or the category “Color”. I understand there are some “include” and “exclude” capabilities through the advanced options, but I’m specifically interested in the pre-populated results that appear on the page and then searching from only those pre-populated results.

    Is this possible?

    Thank you.

    Nate

    #15390
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Nate,

    This might actually be possible with a custom code. I have made a sample code that may help you out. Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!

    Explanation
    This code executes just before the search query is executed, making it possible to alter the final query arguments. Whenever the ‘force_count’ or the ‘force_order’ search arguments are set, it is certainly an auto populate search query.
    On lines 9-15 there is a new argument added to the taxonomy filter array, allowing only posts from post_tag taxonomy, that belong to tags with ID 1, 2 or 3. Similarly you can edit this code, just enter the taxonomy you want, and the term ID(s). It will force displaying items belonging to those taxonomy terms only.

    I hope this helps!

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #15403
    nloggans
    nloggans
    Participant

    Thanks!

    If I was going to also apply this to different searches within the website – would I also just need to change the “10” and “2” ID numbers in line 4?

    I believe the “2” comes from the ID number for the Ajax Search, but where does the “10” happen to be pulled from?

    Thank you.

    #15405
    nloggans
    nloggans
    Participant
    You cannot access this content.
    #15410
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Nate,

    Line 4 in this case is only the attachment of the filter function to the actual hook. Numbers 10 and 2 are the priority and the accepted arguments number, it is not the search ID.

    However, in the function parameters, variable $id holds the search ID value. So, if you want to separately change these parameters for earch instance, then use this modified code (as example only):

    This is almost the same as the one above, except there is and $id check, so the parameter change can be made on this condition.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


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

You must be logged in to reply to this topic.