Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Filter without a (visible) form

Viewing 10 posts - 1 through 10 (of 75 total)
  • Richard Hartley
    #270592

    Hi,

    I’ve used a form to be allow users to quickly filter out items from 300+ ish results on a search page.

    The fun thing is, it’s actually a lot quicker than the WPBakery filter I have doing the same on some of my landing pages – I’m actually having problems with their performance because of the number of queries they’re performing.

    The search page I have set up uses the WPBakery/S&F tie-in to pull results into a post grid and it works perfectly.

    What I want to do is use the S&F query method on those landing pages, hardcoding the category filters/taxonomies depending on the landing page, and putting the results in the post grid.

    I have a suspicion I need to do something using edit_query_arguments(), but I’m not quite sure how to go about it or where to put it on the individual landing pages.

    Could you please advise?

    Trevor Moderator
    #270595

    You can make a form with no Form UI elements, and then use conditions set in the Posts, Tags, Categories & Taxonomies and Post meta settings tab to pre-filter/sort the page.

    I am not sure you then need the form on the page as well, but if you do, you can hide it using CSS.

    If you need more sophisticated pre-filtering, you have have to do it instead using this filter;

    https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments

    Richard Hartley
    #270596

    Thanks Trevor,

    I hadn’t thought of using a blank form. I’ll try that first as a proof of concept. I have over 150 landing pages though, so I’d rather avoid having to create that many forms 😛

    I took a look at that URL, but I wasn’t sure where to put it in the overall scheme of the page? If you could please help me clarify…

    I assume that in this line: $query_args['somearg'] = 'newvalue';

    I should be replacing “somearg” with the fieldname and “newvalue” with the value I want to filter on in said fieldname?

    Similarly, if I want to filter on two variables, I can just repeat that line, making changes as applicable?

    I’m using php snippets at the moment to insert code. Where should this function go in relation to the search results post grid? Right now I don’t think the new arguments are being picked up as a var_dump on $query_args returns NULL.

    Trevor Moderator
    #270598

    The filter would be used in the child theme functions.php file. I think you would have to make that many forms. Far from ideal.

    Richard Hartley
    #270599

    I’m hoping that, with the right methodology, simply applying the filter on each page should suffice.

    Given that each page slug contains the keywords I need to amend the query, the theory is that I can extract them from the slug and use them to populate the “somearg” and “value” fields appropriately and pass those to the search results.

    Or am I completely misunderstanding how it works?

    Trevor Moderator
    #270601

    You could pass them, yes, I guess. The problem is that most of our form types require a results page URL. But, there are ways of dynamically setting that, provided one is set by default in the form. But, it would all need to be done in PHP.

    This is not something I have tried to do, and would not want to either, as it would be highly complex.

    Richard Hartley
    #270602

    I’m figuring php is the way forward here.

    I’d forgotten about the results page url bit.

    Could you point me in the direction of how I might set it dynamically per page?

    Trevor Moderator
    #270604

    The notes on dynamic url setting are here:

    https://searchandfilter.com/documentation/action-filter-reference/#modify-urls

    You would need to somehow use PHP to fetch the URL and the variables.

    For both filters, there are a lot of snippets also in the forum topics.

    Richard Hartley
    #270640
    This reply has been marked as private.
    Trevor Moderator
    #270714

    The sfid is passed by our form to that function, and will be the Post ID of the form. In this case, is that 27601.

    How can you know? When editing the form, the ID appears in the shortcode for the form in the meta box on the right, or indeed in the browser URL. If on the main Search & Filter page in admin, the shortcodes are also shown there.

Viewing 10 posts - 1 through 10 (of 75 total)

The forum ‘Search & Filter Pro’ is closed to new topics and replies.