Displaying categories in vertical result-listing & using URL with parameters

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Displaying categories in vertical result-listing & using URL with parameters

This topic contains 3 replies, has 2 voices, and was last updated by Even Even 7 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12574
    Even
    Even
    Participant

    Hi.

    I was wondering if you could help me out with a few things. I have three search bars on the site in questioning, but I am only asking about the one on the site I’ve linked in the private details. (Not the one up by the header, but the one in the content). And before I begin I have to apologize for my bad description – English is not my first language.

    1:
    I would like to fetch the categories for each result and display them in my result listing. Is there a simple way to fetch these and display them?
    A way of php echo them or some thing. I tried a var dump, but I couldn’t see any display of my categories.

    2:
    Is it possible to use a parameter in a URL so that it automatically chooses an option in one of the drop down menus when entering the site via. said URL? F.ex “myurl.com/?lokasjon=drammen” would sort the results after “Drammen” when entering the site?

    Thank you.

    #12583
    Even
    Even
    Participant
    You cannot access this content.
    #12588
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Both is possible, but only with custom coding. I will paste some snippets here, which I tested, but please keep in mind that they might not work. Since your request qualifies as customization, please note that I can’t guarantee anything.

    1. Try placing this code to the functions.php file in your theme (or child theme) directory. Change the $taxonomy variable to the taxonomy you want to use. It will go through the results, get the terms for the given taxonomy and put the taxonomies before the final results, and returns the execution to the search thread:

    2. This might be even more difficult, but based on the two select boxes I see, I would recommend starting with something like this:

    This I have not tested. It basically sets a javascript variable if the ‘portfolio_entries’ or the ‘kategori’ query variable is set in the url (when the page loads), like domain.com?kategori=1
    Please note that the values must be the IDs of the taxonomy term (numeric) in this case, not words. So domain.com?kategori=xyz will not work, only for example: domain.com?kategori=23

    I hope this helps in some way!

    Best,
    Ernest Marcinko

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


    #12615
    Even
    Even
    Participant

    Thank you very much for your response. I am very grateful that you took your time to answer, even though it qualifies as customization.

    Regarding the first issue: There seem to be something happening, but not exactly what I’m looking for. When adding your code to my functions.php file, the taxonomy “lokasjoner” starts popping up in my results for the top bar – search bar, as independent results. I do not see them in the search results in the content on the page linked in my first post.
    I was hoping to make it possible to show the taxonomy for each result in the vertical list-view.

    F.ex. if I could add something like
    <?php echo get_the_category() ?> in the vertical.php template, under where the title is being fetched. And then the category would show up in the result listing. Is this difficult? I understand that this is beyond the support, but if you were to know how to achieve this – I would be glad.

    Thank you again.

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

You must be logged in to reply to this topic.