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 Manually get results

Viewing 5 posts - 1 through 5 (of 5 total)
  • Cody Henderson
    #141984

    Is there a way to manually get the results, without having to use a results page.
    I want to be able to create a query, use search and filter on it, and then access the results all in the backend.

    I have a custom api that will accept a search term, build a query, and return the categories for the search term. I want to attach search and filter to this and then get the categories search and filter generates.

    Trevor Moderator
    #142055

    I am not entirely certain what you are doing with this, but WordPress needs to post the query to a page, which you could then use this to grab the query array:

    $sf_current_query = $searchandfilter->get(7050)->current_query()->get_array();
    

    Where you change the ID to the form ID of your form.

    Cody Henderson
    #142940

    I just want to use search and filter for the backend. Instead of search and filter posting the query to a page, I want to create and use it in the same scope.

    Is any way I can call the results instead of waiting for them to post to me?

    Trevor Moderator
    #142997
    This reply has been marked as private.
    Ross Moderator
    #144371

    Hi Cody

    Off the top of my head, I’m not sure S&F will work as is in the backend (it was never designed for that).

    S&F runs different code depending on whether you are in wp-admin or not.

    Generally speaking though, you can attach S&F to any query you create. So there might be an option for you to create your query in an ajax call (S&F should work in wp-ajax, even though its technically in admin) and you could wrap your results as a JSON object, from which you would need to parse with Javascript and take any necessary actions after that .

    In order to add S&F to your query you would need to add the argument search_filter_id.

    eg:

    $args = array(
        'post_type' => 'post',
        'search_filter_id' => 1234
    );
    $my_query = new WP_Query($args);

    Hope that helps.

    Best

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

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