Manually get results

Forums › Forums › Search & Filter Pro › Manually get results

Viewing 5 posts – 1 through 5 (of 5 total)
  • Anonymous
    #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
    #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.

    Anonymous
    #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
    #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)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.