Filter for custom fields

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #25845
    baumelerch71
    baumelerch71
    Participant

    Hi
    I have different pages to display my post with specific custom fields values. For example all post with the “cf: color” and “value: blue” are displayed on one page, posts with “color = green” on another (similar to an archive page).
    Now I want to filter these pages for another custom field: “form = round” but when i do that I get redirected to the search results page and as results i get all posts with “form = round”. But of course, when coming from the page “blue” i still want to have this filter intact and end up with “color = blue & form = round”.
    Is there an easy way to get that result?
    Perfect would be if i could stay on my site “blue” and just filter those posts, whithout switching to the search results page.
    Basicly i’d just have to always have the current custom field value set as the standart filter, is this possible? Is there another way?

    Please let me know if you have any questions.

    Thank you and kind regards
    Stefan

    #25847
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    If I understand this correctly, you have multiple search bars on different pages, that lead to a search results page where is another search bar – and you want to set the filter value as set on the source page?

    I’m afraid that is not possible between different search instances. It works with the same search bar, but not between different ones unfortunately.

    Best,
    Ernest Marcinko

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


    #25850
    baumelerch71
    baumelerch71
    Participant

    I’m actually using the same search bar on different pages (always [wd_asp id=3]).
    In this search bar i have two custom field filters. One filter for “color” and one for “form”.

    On the page with with all the “blue” post i’d like to have the filter “color” dynamically set to a standart value “blue” so if i select “form = round” it also takes the predifined “color = blue” so i end up on the search results pag with “color = blue & form = round”.

    The problem is just to dynamically set the standart value for the filter, based on the custom field (or some other field if that would work better).
    With dynamically I mean, if Im on the page “blue” the filter: color is set to blue, on the page “green” it’s set to green, on the page “round” though the filter “form” would be set to round. But it’s always the same search bar ([wd_asp id=3]).

    If that’s not possible, do you have another tip for me to accchieve something similar?

    Stefan

    #25873
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Stefan,

    Okay, I see now. Actually there is a way, it is a bit tricky, but possible.

    Before starting, set the filters as you want them on the destination page, then:

    1. Open up the browser developer tools, by hitting F12 on your keyboard, while the search page is open, the reload the page. You should see the developer console.

    2. Navigate to the Console panel, then copy/paste the following code there like so:

    ASP.api(3, 1, 'getStateURL')

    Note: The first number after the parentheses is the search ID (3), if you use different one, make sure to replace that.

    3. After hitting enter, it will print out a string. Copy that, it contains the URL to the current page with the preset filter states: https://i.imgur.com/RwuZqWM.png

    4. Change the filters as you like, and just do step 2. each time, no need to reload the page, it will always print the URL with the changes.

    Best,
    Ernest Marcinko

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


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

You must be logged in to reply to this topic.